buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
#include <bits/stdc++.h> using namespace std; int main() { int N, M, sum = 0; cin >> N >> M; int day[M]; for (int i = 0; i < M; i++) { cin >> day[M]; sum += day[M]; } if (sum >= N) cout << "-1"; else cout << N - sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int N, M, sum = 0; cin >> N >> M; int day[M]; for (int i = 0; i < M; i++) { cin >> day[M]; sum += day[M]; } if (sum > N) cout << "-1"; else cout << N - sum; return 0; }
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
85
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; #define LL long long int N, M, A[11111]; int main() { cin >> N >> M; for (...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; #define LL long long int N, M, A[11111]; int main() { cin >> N >> M; for (...
[["+", 0, 1, 0, 16, 31, 16, 12, 2, 63, 22], ["-", 31, 16, 12, 23, 0, 41, 15, 16, 31, 22], ["-", 31, 16, 12, 23, 0, 41, 15, 16, 17, 18], ["-", 31, 16, 12, 23, 0, 41, 15, 16, 12, 13], ["-", 0, 16, 31, 16, 12, 23, 0, 41, 0, 101], ["-", 0, 16, 31, 16, 12, 23, 0, 41, 0, 102], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 21]]
1
100
#include <iostream> using namespace std; int n, m, a[10009]; int main() { cin >> n >> m; for (int i = 0; i < m; i++) cin >> a[i]; for (int i = 0; i < m; i++) n -= a[i]; cout << (n >= 0) ? n : -1; return 0; }
#include <iostream> using namespace std; int n, m, a[10009]; int main() { cin >> n >> m; for (int i = 0; i < m; i++) cin >> a[i]; for (int i = 0; i < m; i++) n -= a[i]; cout << (n >= 0 ? n : -1); return 0; }
[["-", 0, 1, 0, 41, 15, 16, 12, 23, 0, 25], ["+", 8, 9, 0, 1, 0, 16, 12, 23, 0, 25]]
1
85
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define INF 100100100 using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; int main() { ll n, m; cin >> n >> m; ll sum = 0; vector<int> a(m); rep(i, m) { cin >> a[i]; sum += a[i];...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; ++i) #define INF 100100100 using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; int main() { ll n, m; cin >> n >> m; ll sum = 0; vector<int> a(m); rep(i, m) { cin >> a[i]; sum += a[i];...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
126
#include <stdio.h> int main(void) { int N, M, day[1000]; scanf("%d%d", &N, &M); int left = N; for (int i = 0; i < M; i++) { scanf("%d", &day[i]); left = left - day[i]; } if (left < 0) { printf("-1"); } else { printf("%d", left); } }
#include <stdio.h> int main(void) { int N, M, day[10000]; scanf("%d%d", &N, &M); int left = N; for (int i = 0; i < M; i++) { scanf("%d", &day[i]); left = left - day[i]; } if (left < 0) { printf("-1"); } else { printf("%d", left); } }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
102
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { int x; cin >> x; n -= x; if (n <= 0) break; } if (n <= 0) cout << -1; else cout << n; }
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; for (int i = 1; i <= m; i++) { int x; cin >> x; n -= x; if (n < 0) break; } if (n < 0) cout << -1; else cout << n; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
73
s = [input() for i in range(2)] li1 = list(map(int, s[0].split())) li2 = list(map(int, s[1].split())) k=0; for j in li2: k+=j print(k) if li1[0] > k or li1[0] == k: print(li1[0]-k) else: print('-1')
s = [input() for i in range(2)] li1 = list(map(int, s[0].split())) li2 = list(map(int, s[1].split())) k=0; for j in li2: k+=j if li1[0] > k or li1[0] == k: print(li1[0]-k) else: print('-1')
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
98
import numpy as np length,hm = map(int,input().split()) time = list(map(int,input().split())) ans = length - np.sum(time) if ans > 0: print(ans) else: print(-1)
import numpy as np length,hm = map(int,input().split()) time = list(map(int,input().split())) ans = length - np.sum(time) if ans >= 0: print(ans) else: print(-1)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20]]
5
63
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> a(M); for (int i = 0; i < M; i++) { cin >> a.at(i); N -= a.at(i); } if (N > 0) { cout << N << endl; } else { cout << -1 << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> a(M); for (int i = 0; i < M; i++) { cin >> a.at(i); N -= a.at(i); } if (N < 0) { cout << -1 << endl; } else { cout << N << endl; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["-", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
89
n,m = map(int,input().split()) a = list(map(int,input().split())) if n-sum(a) < 0: print(0) else: print(n-sum(a))
n,m = map(int,input().split()) a = list(map(int,input().split())) if n-sum(a) < 0: print(-1) else: print(n-sum(a))
[["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612]]
5
58
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int Days = N; for (int i = 1; i <= M; i++) { int A; cin >> A; Days -= A; if (A < 0) { cout << -1 << endl; return 0; } } cout << Days << endl; return 0; }
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int Days = N; for (int i = 0; i < M; i++) { int A; cin >> A; Days -= A; if (Days < 0) { cout << -1 << endl; return 0; } } cout << Days << endl; return 0; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
81
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N; cin >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); } int ans = N; for (int i = 0; i < M; i++) { ans -= A.at(i); } if (ans > 0) { cout << ans << endl; } else { cout << "-1" << en...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N; cin >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); } int ans = N; for (int i = 0; i < M; i++) { ans -= A.at(i); } if (ans >= 0) { cout << ans << endl; } else { cout << "-1" << e...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
117
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, co...
#include <algorithm> #include <iostream> #include <vector> #define rep(i, n) for (int i = 0; i < n; ++i) #define rep1(i, n) for (int i = 1; i <= n; ++i) using namespace std; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, co...
[["-", 0, 1, 0, 11, 31, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 31, 2, 3, 4, 0, 22]]
1
186
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #define SIS std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; typedef long long ll; const int MAX = 0x7ffffff; int n, m; void slove() { cin >> n >> m; l...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #define SIS std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; typedef long long ll; const int MAX = 0x7ffffff; int n, m; void slove() { cin >> n >> m; l...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
118
n,m = map(int,input().split()) a = map(int,input().split()) date = sum(a) if n-date <= 0: print(-1) else: print(n-date)
n,m = map(int,input().split()) a = map(int,input().split()) date = sum(a) if n-date < 0: print(-1) else: print(n-date)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]]
5
56
n,m = map(int, input().split()) a = map(int, input().split()) b = sum(a) if n < sum(a): print(-1) else: print(n-b)
n,m = map(int, input().split()) a = map(int, input().split()) b = sum(a) if n < b: print("-1") else: print(n-b)
[["-", 0, 656, 0, 57, 15, 666, 0, 652, 63, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 28, 612], ["+", 0...
5
57
#include <iostream> using namespace std; int main() { int N, M, A, i; cin >> N >> M; for (i = 0; i < M; i++) { cin >> A; N -= A; } if (A < 0) cout << -1; else cout << N; return 0; }
#include <iostream> using namespace std; int main() { int N, M, A, i; cin >> N >> M; for (i = 0; i < M; i++) { cin >> A; N -= A; } if (N < 0) { cout << -1; } else { cout << N; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
68
#include <stdio.h> int main() { int m, n, i, sum = 0, ans; scanf("%d%d", &m, &n); for (i = 0; i < n; i++) { scanf("%d", ans); sum += ans; } ans = sum <= m ? m - sum : -1; printf("%d", ans); return 0; }
#include <stdio.h> int main() { int m, n, i, sum = 0, ans; scanf("%d%d", &m, &n); for (i = 0; i < n; i++) { scanf("%d", &ans); sum += ans; } ans = sum <= m ? m - sum : -1; printf("%d", ans); return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
86
#include <stdio.h> int main(void) { int n, m, i; int a[100]; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); } for (i = 0; i < m; i++) { n -= a[i]; if (n < 0) { printf("-1\n"); return 0; } } printf("%d\n", n); return 0; }
#include <stdio.h> int main(void) { int n, m, i; int a[1000000]; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); } for (i = 0; i < m; i++) { n -= a[i]; if (n < 0) { printf("-1\n"); return 0; } } printf("%d\n", n); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
117
#include <iostream> using namespace std; int main() { int holi; int syuku; cin >> holi >> syuku; long int niss; long int tot = 0; int i; for (i = 0; i < syuku; i++) { cin >> niss; tot += niss; } long int ans; if (tot < holi) { cout << " -1" << endl; } else { ans = (long int)holi...
#include <iostream> using namespace std; int main() { int holi; int syuku; cin >> holi >> syuku; long int niss; long int tot = 0; int i; for (i = 0; i < syuku; i++) { cin >> niss; tot += niss; } long int ans; if (tot > holi) { cout << " -1" << endl; } else { ans = (long int)holi...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
102
N,M=map(int, input().split()) A=list(map(int, input().split())) if sum(A)>=N: print(N-sum(A)) else: print(-1)
N,M=map(int, input().split()) A=list(map(int, input().split())) if sum(A)<=N: print(N-sum(A)) else: print(-1)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19]]
5
57
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); long long n, m; cin >> n >> m; int s = 0; while (m--) { int a; cin >> a; s += a; } if (n - s < 1) cout << -1; cout << n - s; }
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); long long n, m; cin >> n >> m; int s = 0; while (m--) { int a; cin >> a; s += a; } if (n - s < 0) cout << "-1"; else cout << n - s; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 62], ["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
83
#include <iostream> using namespace std; int main() { int n, m, a; cin >> n >> m; while (cin >> a) { n -= a; } if (n <= 0) cout << -1; else cout << n; return 0; }
#include <iostream> using namespace std; int main() { int n, m, a; cin >> n >> m; while (cin >> a) { n -= a; } if (n < 0) cout << -1; else cout << n; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
55
#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long a, b, c; cin >> a >> b; long long sum = 0; for (long long i = 0; i < b; i++) { cin >> c; sum += c; } if (sum >= a) cout << sum - a; else cout << -1; }
#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long a, b, c; cin >> a >> b; long long sum = 0; for (long long i = 0; i < b; i++) { cin >> c; sum += c; } if (sum <= a) cout << a - sum; else cout << -1; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 57, 64, 1, 0, 16, 12, 16, 31, 22], ["-", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 12, 22]]
1
95
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c = 0, d[1000001], i; string s; cin >> a >> b; for (i = 1; i <= a; i++) { cin >> d[i]; c = c + d[i]; } if (c > a) { cout << -1; } if (c <= a) { if (c == a) { cout << 0; } else { cout << a - c; ...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c = 0, d[1000001], i; string s; cin >> a >> b; for (i = 1; i <= b; i++) { cin >> d[i]; c = c + d[i]; } if (c > a) { cout << -1; } if (c <= a) { if (c == a) { cout << 0; } else { cout << a - c; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
110
#include <stdio.h> int main() { int n, m; int a[1005]; int sum = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a[i]); sum = sum + a[i]; } if (n < sum) printf("%d", -1); else printf("%d", n - sum); return 0; }
#include <stdio.h> int main() { int n, m; int a[10001]; int sum = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a[i]); sum = sum + a[i]; } if (n < sum) printf("%d", -1); else printf("%d", n - sum); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
105
N, M, *A = map(int, open(0).read().split()) print(N - sum(A))
N, M, *A = map(int, open(0).read().split()) print(max(N - sum(A), -1))
[["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 657, 12, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 3, 4, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 3, 4, 0, 652, 3, 4, 0, 664, 28, 612]]
5
33
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; for (int i = 0; i < N; i++) { int A; cin >> A; sum += A; } int ans; if (N < sum) { ans = -1; } else { ans = N - sum; } cout << ...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; for (int i = 0; i < M; i++) { int A; cin >> A; sum += A; } int ans; if (N < sum) { ans = -1; } else { ans = N - sum; } cout << ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
94
#include <stdio.h> int main() { int n; int m; int a; int sum = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a); sum += a; } if (sum < n) { printf("%d", n - sum); } else printf("-1"); return 0; }
#include <stdio.h> int main() { int n; int m; int a; int sum = 0; scanf("%d %d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d", &a); sum += a; } if (sum <= n) { printf("%d", n - sum); } else printf("-1"); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19]]
0
95
mn = input().split() mn = [int(x) for x in mn] n = mn[0] m = mn[1] a = input().split() a = [int(x) for x in a] total = sum(a) if n-total <0: print('-1') else: prtin(n-total)
mn = input().split() mn = [int(x) for x in mn] n = mn[0] m = mn[1] a = input().split() a = [int(x) for x in a] total = sum(a) if n-total <0: print('-1') else: print(n-total)
[["-", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 652, 63, 22]]
5
81
#define ll long long #define ldd long double #define mpp make_pair #define pb push_back #define ff first #define ss second #include <bits/stdc++.h> using namespace std; int main() { ll n, m, y, x, z, h, t, i, j, k; ll cnt = 0, cnt1 = 0, sum = 0, sum1 = 0, flag = 0, flag1 = 0, maxi = LLONG_MIN, mini = LLONG_MAX...
#define ll long long #define ldd long double #define mpp make_pair #define pb push_back #define ff first #define ss second #include <bits/stdc++.h> using namespace std; int main() { ll n, m, y, x, z, h, t, i, j, k; ll cnt = 0, cnt1 = 0, sum = 0, sum1 = 0, flag = 0, flag1 = 0, maxi = LLONG_MIN, mini = LLONG_MAX...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
149
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String l = sc.nextLine(); String[] arr1 = l.split(" "); l = sc.nextLine(); String[] arr2 = l.split(" "); Integer dSum = 0; for (String s : arr2) { dSum += Int...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String l = sc.nextLine(); String[] arr1 = l.split(" "); l = sc.nextLine(); String[] arr2 = l.split(" "); Integer dSum = 0; for (String s : arr2) { dSum += Int...
[["-", 0, 492, 3, 4, 0, 510, 15, 16, 17, 47], ["+", 0, 492, 3, 4, 0, 510, 15, 16, 17, 20]]
3
140
#include <bits/stdc++.h> using namespace std; void PDF(long long n, long long m, long long A[]) { int i, s = 0, t; for (i = 0; i < m; i++) { s = s + A[i]; } t = n - s; if (s < 0) { cout << "-1" << endl; } else { cout << t << endl; } } int main() { long long n, m, i, A[100000]; cin >> n >> ...
#include <bits/stdc++.h> using namespace std; void PDF(long long n, long long m, long long A[]) { int i, s = 0, t; for (i = 0; i < m; i++) { s = s + A[i]; } t = n - s; if (t < 0) { cout << "-1" << endl; } else { cout << t << endl; } } int main() { long long n, m, i, A[100000]; cin >> n >> ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
148
#include <iostream> using namespace std; int main() { int N, M, ans = 0, a; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> a; ans += a; } ans = N - ans; if (N >= 0) cout << ans; else cout << -1; }
#include <iostream> using namespace std; int main() { int N, M, ans = 0, a; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> a; ans += a; } ans = N - ans; if (ans >= 0) cout << ans; else cout << -1; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
74
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower) using namespace std; using ll = long long; int main() { int n, m; ll sum = 0; cin >> n >> m; rep(i, m) { int a; cin >> a; sum += a; } if (n < m) cout...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower) using namespace std; using ll = long long; int main() { int n, m; ll sum = 0; cin >> n >> m; rep(i, m) { int a; cin >> a; sum += a; } if (n < sum) co...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
96
#include <iostream> using namespace std; int main() { int N, M; int A[10010]; cin >> N; int ans = 0; for (int i = 0; i < M; i++) { cin >> A[i]; ans += A[i]; } if (ans <= N) { cout << N - ans << endl; } else { cout << "-1" << endl; } }
#include <iostream> using namespace std; int main() { int N, M; int A[10010]; cin >> N >> M; int ans = 0; for (int i = 0; i < M; i++) { cin >> A[i]; ans += A[i]; } if (ans <= N) { cout << N - ans << endl; } else { cout << "-1" << endl; } }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
89
N, M = map(int, input().split()) A = list(map(int, input(),split())) sum = sum(A) if sum > N: ans = -1 else: ans = N - sum print(ans)
N, M = map(int, input().split()) A = list(map(int, input().split())) B = sum(A) if B > N: ans = -1 else: ans = N - B print(ans)
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22], ["...
5
59
<?php fscanf(STDIN,"%d %d",$n,$m); $a = explode(" ", trim(fgets(STDIN))); foreach($a as $value){ $n -= $value; if($n <= 0){ echo -1; return; } } echo $n;
<?php fscanf(STDIN,"%d %d",$n,$m); $a = explode(" ", trim(fgets(STDIN))); foreach($a as $value){ $n -= $value; if($n < 0){ echo -1; return; } } echo $n;
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
6
69
vacationDayCount, homeworkCount = map(int, input().split()) requiredDayList = list(map(int, input.split())) playableDayCount = vacationDayCount - sum(requiredDayList) if(playableDayCount >= 0): print(playableDayCount) else: print(-1)
vacationDayCount, homeworkCount = map(int, input().split()) requiredDayList = list(map(int, input().split())) playableDayCount = vacationDayCount - sum(requiredDayList) if(playableDayCount >= 0): print(playableDayCount) else: print(-1)
[["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 25]]
5
57
n,m = map(int,input().split()) A = list(map(int,input(),split())) a = sum(A) if n>=a: print(n-a) else: print(-1)
N, M = map(int, input().split()) A = list(map(int, input().split())) a = sum(A) if N>=a: print(N-a) else: print(-1)
[["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+",...
5
57
#include <stdio.h> #include <stdlib.h> int main(void) { int days; int num; int sum; int day; scanf("%d %d", &days, &num); sum = 0; for (int i = 0; i < num; i++) { scanf("%d", &day); sum += day; } if (days - sum > 0) { printf("%d\n", (days - sum)); } else { printf("-1\n"); } retu...
#include <stdio.h> #include <stdlib.h> int main(void) { int days; int num; int sum; int day; scanf("%d %d", &days, &num); sum = 0; for (int i = 0; i < num; i++) { scanf("%d", &day); sum += day; } if (days - sum >= 0) { printf("%d\n", (days - sum)); } else { printf("-1\n"); } ret...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
108
n = input().split() m = input().split() n = [int(i) for i in n] m = [int(i) for i in m] a = n[0] for i in m: a -= i if a<0: print("-1") print(a)
n = input().split() m = input().split() n = [int(i) for i in n] m = [int(i) for i in m] a = n[0] for i in m: a -= i if a<0: print("-1") else: print(a)
[["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 95], ["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 102]]
5
71
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a.at(i); } int ans = 0; for (int j = 0; j < m; j++) { ans += a.at(j); } int g = n - ans; if (ans >= n) { cout << g << endl; } else { cout <<...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(m); for (int i = 0; i < m; i++) { cin >> a.at(i); } int ans = 0; for (int j = 0; j < m; j++) { ans += a.at(j); } int g = n - ans; if (ans <= n) { cout << g << endl; } else { cout <<...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 1, 0, 16, 31, 16, 12, 103, 0, 104], ["-", 0, 1, 0, 16, 31, 16, 12, 103, 0, 125], ["-", 0, 16, 31, 16, 12, 103, 0, 42, 0, 13], ["+", 0, 9, 0, 1, 0, 16, 31, 16, 12, 13]]
1
120
N,M = map(int, input().split()) A = [list(map(int,input().split()))] print(A) SUM = sum(A[0]) if SUM>N: print(-1) else: print(N-SUM)
N,M = map(int, input().split()) A = [list(map(int,input().split()))] SUM = sum(A[0]) if SUM>N: print(-1) else: print(N-SUM)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
66
#include <bits/stdc++.h> using namespace std; int main() { int N, M, t = 0, a; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> a; t += a; } if (a > N) cout << -1; else cout << N - t; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M, t = 0, a; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> a; t += a; } if (t > N) cout << -1; else cout << N - t; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
70
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, m; cin >> n >> m; while (m--) { int x; cin >> x; n -= x; } if (n > 0) { cout << n << endl; } else cout << -1 << endl; }
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, m; cin >> n >> m; while (m--) { int x; cin >> x; n -= x; } if (n >= 0) { cout << n << endl; } else cout << -1 << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
65
n, m = map(int, input().split()) A = list(map(int, input().split())) flg = 0 cnt = sum(A) if n > cnt: print(n-cnt) else: print('-1')
n, m = map(int, input().split()) A = list(map(int, input().split())) cnt = sum(A) if n >= cnt: print(n-cnt) else: print('-1')
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 20]]
5
61
#include <iostream> using namespace std; int a[10000]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> a[i]; } int b = 0; for (int i = 0; i < m; ++i) { b = b + a[i]; } if (b < n) cout << n - b; else cout << "-1"; }
#include <iostream> using namespace std; int a[10000]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> a[i]; } int b = 0; for (int i = 0; i < m; ++i) { b = b + a[i]; } if (b <= n) cout << n - b; else cout << "-1"; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
101
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A; for (int i = 0; i < M; i++) { cin >> A.at(i); } int sum = 0; for (int i = 0; i < M; i++) { sum += A.at(i); } cout << max(N - sum, -1) << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); } int sum = 0; for (int i = 0; i < M; i++) { sum += A.at(i); } cout << max(N - sum, -1) << endl; }
[["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25]]
1
97
#include <bits/stdc++.h> using namespace std; long long n, m, a[10001], sum = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a[i]; sum += a[i]; } if (n - sum > 0) ...
#include <bits/stdc++.h> using namespace std; long long n, m, a[10001], sum = 0; int main() { ios_base::sync_with_stdio(0); cin.tie(0); // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> a[i]; sum += a[i]; } if (n - sum >= 0)...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
100
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; using ll = long long; int main() { ll n, m; cin >> n >> m; vector<ll> a(m); for (int i = 0; i < m; i++) { cin >> a.at(i); } ll sum = 0; for (int i = 0; i < m; i++) { sum += a.at(i); } if (sum < 0) { cout << -1 << en...
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; using ll = long long; int main() { ll n, m; cin >> n >> m; vector<ll> a(m); for (int i = 0; i < m; i++) { cin >> a.at(i); } ll sum = 0; for (int i = 0; i < m; i++) { sum += a.at(i); } if (n - sum < 0) { cout << -1 <...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33]]
1
127
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; long long sum = 0; for (int i = 0; i < k; i++) { int a; cin >> a; sum += a; } n -= k; if (n >= 0) cout << n << endl; else cout << -1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; long long sum = 0; for (int i = 0; i < k; i++) { int a; cin >> a; sum += a; } n -= sum; if (n >= 0) cout << n << endl; else cout << -1 << endl; }
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22]]
1
79
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <vector> #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)n; i++) using namespace std; int main() { ll N, M; ll tas = 0; ll ans = 0; c...
#include <algorithm> #include <cmath> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <vector> #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)n; i++) using namespace std; int main() { ll N, M; ll tas = 0; ll ans = 0; c...
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
134
#include <cmath> #include <iostream> using namespace std; int main() { int N = 0, M = 0; int x = 0; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> x; N -= x; } if (N > 0) cout << N << endl; else cout << -1; return 0; }
#include <cmath> #include <iostream> using namespace std; int main() { int N = 0, M = 0; int x = 0; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> x; N -= x; } if (N >= 0) cout << N << endl; else cout << -1; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
78
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, s = 0, x; cin >> n >> m; // cout<<n<<m; for (i = 1; i <= m; i++) { cin >> x; s += x; } // cout<<s; if (n - s > 0) cout << n - s; else cout << "-1"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, s = 0, x; cin >> n >> m; // cout<<n<<m; for (i = 1; i <= m; i++) { cin >> x; s += x; } // cout<<s; if (n - s >= 0) cout << n - s; else cout << "-1"; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
77
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n, m; cin >> n >> m; vector<int> a(m); rep(i, m) cin >> a[i]; ll ans = n; rep(i, m) ans -= a[i]; if (n < 0) { cout << "-1" << endl; return ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n, m; cin >> n >> m; vector<int> a(m); rep(i, m) cin >> a[i]; ll ans = n; rep(i, m) ans -= a[i]; if (ans < 0) { cout << "-1" << endl; retur...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
116
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> day(M); for (int i = 0; i < M; i++) { cin >> day.at(i); } int sum = 0; //宿題を終わらせるのにかかる日数 for (int i = 0; i < M; i++) { sum += day.at(i); } if (N > sum) { cout << N - sum << endl; } else { ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> day(M); for (int i = 0; i < M; i++) { cin >> day.at(i); } int sum = 0; //宿題を終わらせるのにかかる日数 for (int i = 0; i < M; i++) { sum += day.at(i); } if (N >= sum) { cout << N - sum << endl; } else {...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
113
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; // 合計点を表す変数 int x; // 入力を受け取る変数 int i = 0; // カウンタ変数 while (i < M) { cin >> x; sum += x; i++; } if (x < 0) { sum = N + 1; } cout << N - sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; // 合計点を表す変数 int x; // 入力を受け取る変数 int i = 0; // カウンタ変数 while (i < M) { cin >> x; sum += x; i++; } if (N < sum) { sum = N + 1; } cout << N - sum << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
80
#include <iostream> #include <stdio.h> using namespace std; int main() { int n, m, a[1001]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; n = n - a[i]; } if (n < 0) { cout << -1 << endl; } else { cout << n << endl; } return 0; }
#include <iostream> #include <stdio.h> using namespace std; int main() { int n, m, a[10001]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; n = n - a[i]; } if (n < 0) { cout << -1 << endl; } else { cout << n << endl; } }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35]]
1
88
#include <bits/stdc++.h> using namespace std; int main(void) { int N, M, sum = 0, res; cin >> N >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); sum += A.at(i); } res = N - sum; if (res > 0) { cout << res << endl; } else { cout << "-1" << endl; } return 0;...
#include <bits/stdc++.h> using namespace std; int main(void) { int N, M, sum = 0, res; cin >> N >> M; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); sum += A.at(i); } res = N - sum; if (res >= 0) { cout << res << endl; } else { cout << "-1" << endl; } return 0...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
107
#include <bits/stdc++.h> using namespace std; #define ld long double #define int long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(...
#include <bits/stdc++.h> using namespace std; #define ld long double #define int long long #define pb push_back #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define mi map<int, int> #define mii map<pii, int> #define all(a) (a).begin(), (a).end() #define x first #define y second #define sz(...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
591
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int a, b; cin >> a >> b; int s = 0; for (int i = 0; i < b; i++) { int n; cin >> n; s += n; } if (s >= a) { cout << "-1"; } else { cout << a - s; } }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { int a, b; cin >> a >> b; int s = 0; for (int i = 0; i < b; i++) { int n; cin >> n; s += n; } if (s > a) { cout << "-1"; } else { cout << a - s; } }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
86
def main(): n,m = map(int,input().split()) a = list(map(int,input().split())) s = sum(a) if s<n: print('-1') else: print(n-s) if __name__ == "__main__": main()
def main(): n,m = map(int,input().split()) a = list(map(int,input().split())) s = sum(a) if s>n: print('-1') else: print(n-s) if __name__ == "__main__": main()
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 667, 47]]
5
73
/* @uthor: Amit Kumar user: CodeChef: dr_virus_ ; Codeforces,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> using namespace std; //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; //#define ln mp::cpp_int; #define ll long long #define ld double #define pp pair<l...
/* @uthor: Amit Kumar user: CodeChef: dr_virus_ ; Codeforces,Hackerearth,Hakerrank: dr_virus; */ #include <bits/stdc++.h> using namespace std; //#include <boost/multiprecision/cpp_int.hpp> // namespace mp = boost::multiprecision; //#define ln mp::cpp_int; #define ll long long #define ld double #define pp pair<l...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 57, 64, 1, 0, 16, 12, 16, 31, 22], ["-", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 64, 1, 0, 16, 12, 16, 12, 22]]
1
157
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N, M; vector<int> vec(M); for (int i = 0; i < M; i++) { cin >> vec.at(i); } int sum = 0; for (int i = 0; i < M; i++) { sum += vec.at(i); } int x = 0; x = N - sum; if (x >= 0) { cout << x << endl; } else ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> vec(M); for (int i = 0; i < M; i++) { cin >> vec.at(i); } int sum = 0; for (int i = 0; i < M; i++) { sum += vec.at(i); } int x = 0; x = N - sum; if (x >= 0) { cout << x << endl; } els...
[["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
121
import math n,m=map(int,input().split()) arr=list(map(int,input().split())) if sum(arr)<n: print(-1) else: print(n-sum(arr))
import math n,m=map(int,input().split()) arr=list(map(int,input().split())) if sum(arr)>n: print(-1) else: print(n-sum(arr))
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 47]]
5
59
#include <bits/stdc++.h> using namespace std; int main() { int N, M, r = 0; cin >> N >> M; vector<int> vecm(M); for (int i = 0; i < M; i++) { cin >> vecm.at(i); r = vecm.at(i); } if (N - r >= 0) { cout << N - r << endl; } else { cout << -1 << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, M, r = 0; cin >> N >> M; vector<int> vecm(M); for (int i = 0; i < M; i++) { cin >> vecm.at(i); r = r + vecm.at(i); } if (N - r >= 0) { cout << N - r << endl; } else { cout << -1 << endl; } }
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72]]
1
97
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, sum = 0; cin >> n >> m; while (m--) { cin >> a; sum = sum + a; } if (n - sum > 0) cout << n - sum; else cout << -1; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, sum = 0; cin >> n >> m; while (m--) { cin >> a; sum = sum + a; } if (n - sum >= 0) cout << n - sum; else cout << -1; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
65
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int n = 0; int m = 0; std::cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { int a; cin >> a; sum += a; } int ans = -1; if (sum > n) { cout << ans; return 0; } cout << sum - n; return 0;...
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int n = 0; int m = 0; std::cin >> n >> m; int sum = 0; for (int i = 0; i < m; i++) { int a; cin >> a; sum += a; } int ans = -1; if (sum > n) { cout << ans; return 0; } cout << (n - sum); return ...
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 23, 0, 24], ["+", 0, 1, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 1, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 12, 23, 0, 25]]
1
93
#include <stdio.h> int main(void) { int i; unsigned long int N, M, sum; unsigned int A[10000]; sum = 0; scanf("%u %u", &N, &M); for (i = 0; i < M; i++) { scanf("%u", &A[i]); sum = sum + A[i]; } if (N - sum >= 0) { printf("%u", N - sum); } else { printf("-1"); } return 0; }
#include <stdio.h> int main(void) { int i; long long int N, M, sum; long int A[10000]; sum = 0; scanf("%lld %lld", &N, &M); for (i = 0; i < M; i++) { scanf("%ld", &A[i]); sum = sum + A[i]; } if (N - sum >= 0) { printf("%ld", N - sum); } else { printf("-1"); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
116
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; // 合計点を表す変数 int x; // 入力を受け取る変数 int i = 0; // カウンタ変数 while (i < M) { cin >> x; sum += x; i++; } if (N - sum >= 0) { cout << N - x << endl; } else { cout << -1 << endl; } }...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; // 合計点を表す変数 int x; // 入力を受け取る変数 int i = 0; // カウンタ変数 while (i < M) { cin >> x; sum += x; i++; } if (N - sum >= 0) { cout << N - sum << endl; } else { cout << -1 << endl; }...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
85
n, m = map(int, input().split()) a = map(int, input().split()) c = 0 for b in a: c += b if n - c <= 0: print(-1) else: print(n-c)
n, m = map(int, input().split()) a = map(int, input().split()) c = 0 for b in a: c += b if n - c < 0: print(-1) else: print(n-c)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]]
5
61
#include <stdio.h> int main() { int n, m, i, p, d = 0; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", p); d += p; } if (d > n) printf("-1"); else printf("%d", n - d); return 0; }
#include <stdio.h> int main() { int n, m, i, p, d = 0; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &p); d += p; } if (d > n) printf("-1"); else printf("%d", n - d); return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67]]
0
90
a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) sum=b.inject(&:+).to_i puts a[0]-sum>0? a[0]-sum:-1
a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) sum=b.inject(&:+).to_i puts a[0]-sum>=0? a[0]-sum:-1
[["-", 0, 652, 3, 4, 0, 754, 15, 738, 17, 47], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 17, 20]]
4
52
#include <iostream> using namespace std; int main() { int N, M; int sum = 0; cin >> N; cin >> M; int input; for (int i = 0; i < M; i++) { cin >> input; sum += input; } if ((N - M) > 0) { cout << (N - M); } else { cout << -1; } return 0; }
#include <iostream> using namespace std; int main() { int N, M; int sum = 0; cin >> N; cin >> M; int input; for (int i = 0; i < M; i++) { cin >> input; sum += input; } if ((N - sum) >= 0) { cout << (N - sum); } else { cout << -1; } return 0; }
[["-", 15, 339, 51, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 23, 0, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 0, 1, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 1, 0, 16, 12, 23, 0, 16, 12, 22]]
1
87
#include <bits/stdc++.h> using namespace std; int main() { int M, N, i, cnt = 0; int free; cin >> N >> M; vector<int> hw(M); for (i = 0; i < M; i++) { cin >> hw.at(i); cnt += hw.at(i); } free = N - cnt; if (free > 0) cout << free << endl; else cout << "-1" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int M, N, i, cnt = 0; int free; cin >> N >> M; vector<int> hw(M); for (i = 0; i < M; i++) { cin >> hw.at(i); cnt += hw.at(i); } free = N - cnt; if (free >= 0) cout << free << endl; else cout << "-1" << endl; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
101
N,m = input().split() M = int(m) L1 = list(map(int,input().split())) ans=-1 if sum(L1)<=N: ans = N - sum(L1) print(ans)
n,m = input().split() N = int(n) L1 = list(map(int,input().split())) ans=-1 if sum(L1)<=N: ans = N-sum(L1) print(ans)
[["-", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
58
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int temp = 0; int flag = 1; for (int i = 0; i < M; i++) { cin >> temp; N = N - temp; if (N <= 0) { cout << -1 << endl; flag = 0; break; } } if (flag) cout << N << endl; return 0; }
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int temp = 0; int flag = 1; for (int i = 0; i < M; i++) { cin >> temp; N = N - temp; if (N < 0) { cout << -1 << endl; flag = 0; break; } } if (flag) cout << N << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
92
#include <bits/stdc++.h> using namespace std; int main() { int N, M, L, K; cin >> N >> M; L = 0; vector<int> Ass(M); for (int i = 0; i < M; i++) { cin >> Ass.at(i); } for (int j = 0; j < M; j++) { L = L + Ass.at(j); } if (N < L) K = -1; else K = L - N; cout << K << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M, L, K; cin >> N >> M; L = 0; vector<int> Ass(M); for (int i = 0; i < M; i++) { cin >> Ass.at(i); } for (int j = 0; j < M; j++) { L = L + Ass.at(j); } if (N < L) K = -1; else K = N - L; cout << K << endl; }
[["-", 75, 76, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 75, 76, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 75, 76, 0, 1, 0, 11, 12, 16, 12, 22]]
1
115
N,M = input().split() A = list(map(int, input().split())) S =sum(A) if N-S >=0: print(N-S) else: print("-1")
N,M = map(int, input().split()) A = list(map(int, input().split())) S =sum(A) if N-S >=0: print(N-S) else: print("-1")
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
55
#include <bits/stdc++.h> #define endl '\n' using namespace std; int CountHangOut(vector<int> Array, int Days) { int ans = Days; for (int i = 0; i < Array.size(); i++) { ans -= Array[i]; } if (ans < -1) ans = -1; return ans; } int main() { int N, M, A_item; vector<int> A; cin >> N >> M; for (in...
#include <bits/stdc++.h> #define endl '\n' using namespace std; int CountHangOut(vector<int> Array, int Days) { int ans = Days; for (int i = 0; i < Array.size(); i++) { ans -= Array[i]; } if (ans < -1) ans = -1; return ans; } int main() { int N, M, A_item; vector<int> A; cin >> N >> M; for (in...
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
134
#include <bits/stdc++.h> using namespace std; int main() { int a, cnt = 0; cin >> a; int b; cin >> b; for (int i = 1; i <= b; i++) { int d; cin >> d; cnt += d; } if (cnt - a < 0) { cout << "-1"; } else { cout << a - cnt; } }
#include <bits/stdc++.h> using namespace std; int main() { int a, cnt = 0; cin >> a; int b; cin >> b; for (int i = 1; i <= b; i++) { int d; cin >> d; cnt += d; } if (a - cnt < 0) { cout << "-1"; } else { cout << a - cnt; } }
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
82
#include <bits/stdc++.h> using namespace std; int main() { int N, M, i; cin >> N; cin >> M; int j = 0; int sum = 0; while (j < M) { cin >> i; j++; sum += i; } if (N - sum >= 0) { cout << N - sum << endl; } cout << -1 << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M, i; cin >> N; cin >> M; int j = 0; int sum = 0; while (j < M) { cin >> i; j++; sum += i; } if (N - sum >= 0) { cout << N - sum << endl; } else { cout << -1 << endl; } }
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
80
n, m = map(int,input().split()) li = list(map(int, input().split())) res = n - li.sum() if res >= 0: print(res) else: print(-1)
n, m = map(int,input().split()) li = list(map(int, input().split())) res = n - sum(li) if res >= 0: print(res) else: print(-1)
[["-", 0, 662, 12, 657, 12, 652, 63, 319, 500, 22], ["-", 0, 662, 12, 657, 12, 652, 63, 319, 0, 131], ["+", 0, 662, 12, 657, 12, 652, 3, 4, 0, 22]]
5
58
#include <stdio.h> int main() { long int n, t, i, sum = 0, a[1005]; scanf("%ld %ld", &n, &t); for (i = 0; i < t; i++) { scanf("%d", &a[i]); sum = sum + a[i]; } if (n >= sum) { printf("%ld\n", n - sum); } else { printf("-1\n"); } return 0; }
#include <stdio.h> int main() { long int n, t, i, sum = 0, a[10005]; scanf("%ld %ld", &n, &t); for (i = 0; i < t; i++) { scanf("%ld", &a[i]); sum = sum + a[i]; } if (n >= sum) { printf("%ld\n", n - sum); } else { printf("-1\n"); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
109
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N, M; int W = 0; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); W = W + A.at(i); } if (N >= W) { cout << N - W << endl; } else { cout << "-1" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int W = 0; vector<int> A(M); for (int i = 0; i < M; i++) { cin >> A.at(i); W = W + A.at(i); } if (N >= W) { cout << N - W << endl; } else { cout << "-1" << endl; } }
[["-", 0, 14, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]]
1
100
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; int x; for (int i = 1; i < M; i++) { cin >> x; sum += x; } if (N >= sum) { cout << N - sum << endl; } else if (N < sum) { cout << "-1" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int sum = 0; int x; for (int i = 0; i < M; i++) { cin >> x; sum += x; } if (N >= sum) { cout << N - sum << endl; } else if (N < sum) { cout << "-1" << endl; } }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
88
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> work(M); for (int i = 0; i < M; i++) { cin >> work.at(i); } int sum = 0; for (int i = 0; i < M; i++) { sum = sum + work.at(i); } if (N - sum > 0) { cout << N - sum << endl; } else { ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> work(M); for (int i = 0; i < M; i++) { cin >> work.at(i); } int sum = 0; for (int i = 0; i < M; i++) { sum = sum + work.at(i); } if (N - sum >= 0) { cout << N - sum << endl; } else { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62]]
1
116
#include <iostream> using namespace std; int main() { unsigned int i, n, m, sum = 0, a[1000]; cin >> n >> m; for (i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum > n) cout << -1; else cout << n - sum; return 0; }
#include <iostream> using namespace std; int main() { int i, n, m, sum = 0, a[100000]; cin >> n >> m; for (i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; } if (sum > n) cout << -1; else cout << n - sum; return 0; }
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
84
#include <stdio.h> int main(void) { int N, M, A[1010], i, s = 0; scanf("%d%d", &N, &M); for (i = 0; i < M; i++) { scanf("%d", &A[i]); s = s + A[i]; } if (s <= N) { printf("%d", N - s); } else { printf("-1"); } return 0; }
#include <stdio.h> int main(void) { int N, M, A[20000], i, s = 0; scanf("%d%d", &N, &M); for (i = 0; i < M; i++) { scanf("%d", &A[i]); s = s + A[i]; } if (s <= N) { printf("%d", N - s); } else { printf("-1"); } return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
107
#include <bits/stdc++.h> using namespace std; int main() { int N, M, count = 0; int *A; cin >> N >> M; A = new int[M]; for (int i = 0; i < M; i++) { cin >> A[i]; } for (int i = 0; i < M; i++) { count += A[i]; } if (count < N) cout << N - count << endl; else cout << -1 << endl; ...
#include <bits/stdc++.h> using namespace std; int main() { int N, M, count = 0; int *A; cin >> N >> M; A = new int[M]; for (int i = 0; i < M; i++) { cin >> A[i]; } for (int i = 0; i < M; i++) { count += A[i]; } if (count <= N) cout << N - count << endl; else cout << -1 << endl; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
114
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(M); int sum = 0; for (int i = 0; i < M; i++) { cin >> A.at(i); sum += A.at(i); } if ((N - sum) > 0) { cout << N - sum << endl; } else { cout << "-1" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> A(M); int sum = 0; for (int i = 0; i < M; i++) { cin >> A.at(i); sum += A.at(i); } if (N - sum >= 0) { cout << N - sum << endl; } else { cout << "-1" << endl; } return 0; }
[["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["-", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
105
i = list(map(int, input().split())) a_i = list(map(int, input().split())) n = i[0] m = i[1] print(n - sum(a_i) if n >= n - sum(a_i) else -1)
i = list(map(int, input().split())) a_i = list(map(int, input().split())) n = i[0] m = i[1] print(n - sum(a_i) if n >= sum(a_i) else -1)
[["-", 3, 4, 0, 41, 0, 666, 0, 657, 31, 22], ["-", 3, 4, 0, 41, 0, 666, 0, 657, 17, 33]]
5
67
n, m = map(int, input().split()) a = list(map(int, input().split())) num = 0 for i in range(0, len(a)): num += int(a[i]) print(num) target = n - num if target >= 0: print(target) else: print("-1")
n, m = map(int, input().split()) a = list(map(int, input().split())) num = 0 for i in range(0, len(a)): num += int(a[i]) target = n - num if target >= 0: print(target) else: print("-1")
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
84
#include <stdio.h> int main() { int N, M, A[1000], sum = 0, hang, i; scanf("%d %d", &N, &M); for (i = 0; i < M; i++) { scanf("%d", &A[i]); } for (i = 0; i < M; i++) { sum = sum + A[i]; } hang = N - sum; if (hang >= 0) { printf("%d\n", hang); } else printf("-1\n"); return 0; }
#include <stdio.h> int main() { int N, M, A[10000], sum = 0, hang, i; scanf("%d %d", &N, &M); for (i = 0; i < M; i++) { scanf("%d", &A[i]); } for (i = 0; i < M; i++) { sum = sum + A[i]; } hang = N - sum; if (hang >= 0) { printf("%d\n", hang); } else printf("-1\n"); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
127
#include <algorithm> #include <cstdlib> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <math.h> using namespace std; int main() { int N, M; int A[1000]; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> A[i]; } int sum = 0; for (int i = 0; i < M; i++) { ...
#include <algorithm> #include <cstdlib> #include <iostream> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <math.h> using namespace std; int main() { int N, M; int A[10000]; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> A[i]; } int sum = 0; for (int i = 0; i < M; i++) {...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
118
x, y = map(int,input().split()) arr = list(map(int, input().split()[:y])) s = 0 for i in arr: s += i re = x - s if re > x: print(-1) elif re == x: print(0) else: print(re)
x, y = map(int,input().split()) arr = list(map(int, input().split()[:y])) s = 0 for i in arr: s += i re = x - s if s > x: print(-1) elif s == x: print(0) else: print(re)
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 0, 22], ["-", 0, 656, 0, 57, 75, 665, 15, 666, 0, 22], ["+", 0, 656, 0, 57, 75, 665, 15, 666, 0, 22]]
5
78
#include <stdio.h> #include <stdlib.h> int main(void) { int n, m, i, p = 0; char a[10000]; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%s", &a[i]); p += atoi(a[i]); } if (p > n) { printf("-1"); } else { printf("%d", n - p); } return 0; }
#include <stdio.h> #include <stdlib.h> int main(void) { int n, m, i, p = 0; int a[10000]; scanf("%d%d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &a[i]); p += a[i]; } if (p > n) { printf("-1"); } else { printf("%d", n - p); } return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
0
111
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; long long sum = 0; cin >> n >> m; for (long long i = 0; i < m; i++) { long long a; cin >> a; sum += a; } long long sol = (n - sum >= 0) ? m - sum : -1; cout << sol << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; long long sum = 0; cin >> n >> m; for (long long i = 0; i < m; i++) { long long a; cin >> a; sum += a; } long long sol = (n - sum >= 0) ? n - sum : -1; cout << sol << '\n'; }
[["-", 0, 43, 49, 50, 51, 41, 64, 16, 31, 22], ["+", 0, 43, 49, 50, 51, 41, 64, 16, 31, 22]]
1
85
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("aa_input.txt", "r", stdin); int t = 1; // cin>>t...
#include <algorithm> #include <iostream> #include <list> #include <queue> #include <set> #include <stdio.h> #include <string> #include <vector> using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("aa_input.txt", "r", stdin); int t = 1; // cin>>t...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
125