Submission #772934

# Submission time Handle Problem Language Result Execution time Memory
772934 2023-07-04T13:11:14 Z Lecorbio Potatoes and fertilizers (LMIO19_bulves) C++14
30 / 100
107 ms 10976 KB
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;

priority_queue <int> q;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n; cin >> n;
	ll ans=0, pref=0, a, b;

	for (int i=0; i<n; i++) q.push(0);
	for (int i=0; i<n-1; i++){
        cin >> a >> b;
        pref += (a-b);

        q.push(pref);
        if (pref < q.top()){
            ans += (q.top() - pref);
            q.pop();
            q.push(pref);
        }
	}

	cin >> a >> b;
	pref += (a-b);
	while (pref < q.top()){
        ans += (q.top() - pref);
        q.pop();
	}
	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 12 ms 1172 KB Output is correct
5 Correct 25 ms 1872 KB Output is correct
6 Correct 81 ms 5724 KB Output is correct
7 Correct 107 ms 10976 KB Output is correct
8 Incorrect 91 ms 9140 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 12 ms 1172 KB Output is correct
5 Correct 25 ms 1872 KB Output is correct
6 Correct 81 ms 5724 KB Output is correct
7 Correct 107 ms 10976 KB Output is correct
8 Incorrect 91 ms 9140 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 376 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 392 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 12 ms 1172 KB Output is correct
12 Correct 25 ms 1872 KB Output is correct
13 Correct 81 ms 5724 KB Output is correct
14 Correct 107 ms 10976 KB Output is correct
15 Incorrect 91 ms 9140 KB Output isn't correct
16 Halted 0 ms 0 KB -