# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471561 | 2021-09-09T22:46:25 Z | CaroLinda | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 1 ms | 204 KB |
#include <bits/stdc++.h> #define debug #define ll long long const int MAXN = 5e5+10 ; using namespace std ; int N ; ll C[MAXN] , x , y ; ll ans , p ; priority_queue< ll > q ; int main() { scanf("%d", &N ) ; for(int i = 0 ; i < N ; i++ ) { scanf("%lld %lld", &x, &y ) ; C[i] = x-y ; C[i] += C[i-1] ; } for(int i = 0 ; i < N ; i++ ) { if(C[i] < 0 ) ans -= C[i] , C[i] = 0 ; if(C[i] > C[N-1] ) ans += C[i]-C[N-1] , C[i] = C[N-1] ; q.push(C[i]) ; q.push(C[i]) ; ans += abs(q.top()-C[i]) ; q.pop() ; } printf("%lld\n" , ans ) ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |