답안 #629497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629497 2022-08-14T14:47:56 Z Piokemon Potatoes and fertilizers (LMIO19_bulves) C++17
20 / 100
7 ms 1236 KB
#include <bits/stdc++.h>
using namespace std;

int c[500'009];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b,odp = 0;
    cin >> n;
    c[0] = 0;
    for (int x=1;x<=n;x++){
        cin >> a >> b;
        c[x] = a-b;
        //c[x] -= x;
        c[x] += c[x-1];
    }
    priority_queue<int> slope;
    slope.push(0);
    for (int x=1;x<=n;x++){
        if (c[x] < 0){
            odp += 0 - c[x];
            c[x] = 0;
        }
        if (c[x] > c[n]){
            odp += c[x] - c[n];
            c[x] = c[n];
        }
        slope.push(c[x]);
        if (c[x] < slope.top()){
            odp += slope.top() - c[x];
            slope.pop();
            slope.push(c[x]);
        }
    }
    cout << odp << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 7 ms 1236 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 7 ms 1236 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 332 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 2 ms 388 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 332 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 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Incorrect 7 ms 1236 KB Output isn't correct
12 Halted 0 ms 0 KB -