Submission #940239

# Submission time Handle Problem Language Result Execution time Memory
940239 2024-03-07T06:53:41 Z 12345678 Potatoes and fertilizers (LMIO19_bulves) C++17
24 / 100
67 ms 18908 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=5e5+5;
ll n, a[nx], b[nx], d[nx], res;
priority_queue<ll> pq;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i]>>b[i], d[i]=d[i-1]+(a[i]-b[i]);
    for (int i=1; i<n; i++) 
    {
        if (d[i]<0) res-=d[i], d[i]=0;
        else if (d[i]>d[n]) res+=d[i]-d[n];
        //pq.push(d[i]);
        //pq.push(d[i]);
        //pq.pop();
    }
    cout<<res<<'\n';
    //while (!pq.empty()) cout<<pq.top()<<' ', pq.pop();    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 6 ms 9164 KB Output is correct
5 Correct 11 ms 11356 KB Output is correct
6 Correct 32 ms 14068 KB Output is correct
7 Correct 67 ms 18908 KB Output is correct
8 Correct 52 ms 16980 KB Output is correct
9 Correct 51 ms 16388 KB Output is correct
10 Correct 37 ms 13936 KB Output is correct
11 Correct 38 ms 14080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 6 ms 9164 KB Output is correct
5 Correct 11 ms 11356 KB Output is correct
6 Correct 32 ms 14068 KB Output is correct
7 Correct 67 ms 18908 KB Output is correct
8 Correct 52 ms 16980 KB Output is correct
9 Correct 51 ms 16388 KB Output is correct
10 Correct 37 ms 13936 KB Output is correct
11 Correct 38 ms 14080 KB Output is correct
12 Incorrect 21 ms 12792 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -