Submission #925201

# Submission time Handle Problem Language Result Execution time Memory
925201 2024-02-11T01:28:46 Z 12345678 Potatoes and fertilizers (LMIO19_bulves) C++17
24 / 100
79 ms 12284 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int nx=5e5+5;

ll n, a[nx], b[nx], ans;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i]>>b[i];
    ll i=1, j=1;
    while (i<=n&&j<=n)
    {
        ll mn=min(a[i], b[j]);
        a[i]-=mn;
        b[j]-=mn;
        ans+=mn*abs(i-j);
        if (a[i]==0) i++;
        if (b[j]==0) j++;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 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 7000 KB Output is correct
5 Correct 10 ms 6748 KB Output is correct
6 Correct 31 ms 6800 KB Output is correct
7 Correct 79 ms 8132 KB Output is correct
8 Correct 51 ms 8116 KB Output is correct
9 Correct 52 ms 12284 KB Output is correct
10 Correct 46 ms 10352 KB Output is correct
11 Correct 49 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 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 7000 KB Output is correct
5 Correct 10 ms 6748 KB Output is correct
6 Correct 31 ms 6800 KB Output is correct
7 Correct 79 ms 8132 KB Output is correct
8 Correct 51 ms 8116 KB Output is correct
9 Correct 52 ms 12284 KB Output is correct
10 Correct 46 ms 10352 KB Output is correct
11 Correct 49 ms 10064 KB Output is correct
12 Incorrect 21 ms 8284 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -