Submission #595574

# Submission time Handle Problem Language Result Execution time Memory
595574 2022-07-13T20:35:44 Z AdamGS Potatoes and fertilizers (LMIO19_bulves) C++17
24 / 100
83 ms 14840 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
ll A[LIM], B[LIM];
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  rep(i, n) cin >> A[i] >> B[i];
  ll ans=0, l=0;
  rep(i, n) {
    while(B[i]) {
      while(!A[l]) ++l;
      ll x=min(A[l], B[i]);
      ans+=x*abs(l-i);
      A[l]-=x;
      B[i]-=x;
    }
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 7 ms 1424 KB Output is correct
5 Correct 14 ms 2500 KB Output is correct
6 Correct 42 ms 7504 KB Output is correct
7 Correct 83 ms 14840 KB Output is correct
8 Correct 71 ms 13048 KB Output is correct
9 Correct 66 ms 12316 KB Output is correct
10 Correct 47 ms 10064 KB Output is correct
11 Correct 49 ms 10068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 7 ms 1424 KB Output is correct
5 Correct 14 ms 2500 KB Output is correct
6 Correct 42 ms 7504 KB Output is correct
7 Correct 83 ms 14840 KB Output is correct
8 Correct 71 ms 13048 KB Output is correct
9 Correct 66 ms 12316 KB Output is correct
10 Correct 47 ms 10064 KB Output is correct
11 Correct 49 ms 10068 KB Output is correct
12 Incorrect 22 ms 3952 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -