# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
882297 | 2023-12-03T03:22:23 Z | Requiem | Potatoes and fertilizers (LMIO19_bulves) | C++17 | 69 ms | 13144 KB |
#include<bits/stdc++.h> #define int long long #define pb push_back #define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #define MOD 1000000007 #define INF 1e18 #define fi first #define se second #define endl "\n" #define FOR(i,a,b) for(int i=a;i<=b;i++) #define FORD(i,a,b) for(int i=a;i>=b;i--) #define sz(a) ((int)(a).size()) #define pi 3.14159265359 #define TASKNAME "bulves" template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; } template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; } using namespace std; typedef pair<int,int> ii; typedef pair<int,ii> iii; typedef vector<int> vi; const int MAXN = 5e5 + 9; int n; int a[MAXN],b[MAXN],A,B; main() { fast; if (fopen(TASKNAME".inp","r")){ freopen(TASKNAME".inp","r",stdin); freopen(TASKNAME".out","w",stdout); } cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]>>b[i]; A += a[i]; B += b[i]; } if (A == B){ int ans = 0, bring = 0; for(int i=1;i<=n;i++){ ans += abs(bring); if (a[i] == b[i]) continue; if (a[i] < b[i]) bring -= b[i] - a[i]; else bring += a[i] - b[i]; } cout<<ans<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 6 ms | 6748 KB | Output is correct |
5 | Correct | 10 ms | 6748 KB | Output is correct |
6 | Correct | 31 ms | 6748 KB | Output is correct |
7 | Correct | 69 ms | 10576 KB | Output is correct |
8 | Correct | 53 ms | 13144 KB | Output is correct |
9 | Correct | 52 ms | 12284 KB | Output is correct |
10 | Correct | 37 ms | 9972 KB | Output is correct |
11 | Correct | 37 ms | 10100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 6 ms | 6748 KB | Output is correct |
5 | Correct | 10 ms | 6748 KB | Output is correct |
6 | Correct | 31 ms | 6748 KB | Output is correct |
7 | Correct | 69 ms | 10576 KB | Output is correct |
8 | Correct | 53 ms | 13144 KB | Output is correct |
9 | Correct | 52 ms | 12284 KB | Output is correct |
10 | Correct | 37 ms | 9972 KB | Output is correct |
11 | Correct | 37 ms | 10100 KB | Output is correct |
12 | Incorrect | 16 ms | 8284 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |