답안 #474199

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
474199 2021-09-17T10:45:53 Z hoanghq2004 Potatoes and fertilizers (LMIO19_bulves) C++14
30 / 100
189 ms 11200 KB
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 5e5 + 10;

int n, dif[Nmax];
priority_queue <int> opt;
long long ans;

int main() {
    ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int a, b;
        cin >> a >> b;
        dif[i] = dif[i - 1] + a - b;
    }
    for (int i = 1; i < n; ++i) {
        if (dif[i] < 0) ans -= dif[i], dif[i] = 0;
        opt.push(dif[i]), opt.push(dif[i]);
        opt.pop();
        ans += dif[i];
    }
    while (opt.size()) ans -= min(dif[n], opt.top()), opt.pop();
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 18 ms 1140 KB Output is correct
5 Correct 43 ms 1992 KB Output is correct
6 Correct 113 ms 5724 KB Output is correct
7 Correct 189 ms 11200 KB Output is correct
8 Incorrect 162 ms 9256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 18 ms 1140 KB Output is correct
5 Correct 43 ms 1992 KB Output is correct
6 Correct 113 ms 5724 KB Output is correct
7 Correct 189 ms 11200 KB Output is correct
8 Incorrect 162 ms 9256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 2 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 18 ms 1140 KB Output is correct
12 Correct 43 ms 1992 KB Output is correct
13 Correct 113 ms 5724 KB Output is correct
14 Correct 189 ms 11200 KB Output is correct
15 Incorrect 162 ms 9256 KB Output isn't correct
16 Halted 0 ms 0 KB -