답안 #473505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473505 2021-09-15T15:48:53 Z piotrulo Potatoes and fertilizers (LMIO19_bulves) C++17
100 / 100
463 ms 19376 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<long long>s(n);
    for(auto &x: s){
        int a,b;
        cin>>a>>b;
        x=a-b;
    }
    partial_sum(s.begin(),s.end(),s.begin());
    long long t=0;
    priority_queue<long long,vector<long long>,greater<long long>>q;
    for(int i=0;i<n+2;i++){
        q.push(1ll*0);
    }
    for(auto w : s){
        q.pop();
        t+=max(-w-q.top(), 0LL);
        q.push(-w);
        q.push(-w);
    }
    long long ctr=0;
    while(q.top()!=-s.back()){
        auto x=q.top();
        q.pop();
        t+=ctr*(q.top()-x);
        ctr++;
    }
    cout<<t;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
4 Correct 32 ms 1840 KB Output is correct
5 Correct 66 ms 3232 KB Output is correct
6 Correct 239 ms 6460 KB Output is correct
7 Correct 416 ms 12436 KB Output is correct
8 Correct 400 ms 12464 KB Output is correct
9 Correct 348 ms 14208 KB Output is correct
10 Correct 259 ms 14128 KB Output is correct
11 Correct 301 ms 14112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
4 Correct 32 ms 1840 KB Output is correct
5 Correct 66 ms 3232 KB Output is correct
6 Correct 239 ms 6460 KB Output is correct
7 Correct 416 ms 12436 KB Output is correct
8 Correct 400 ms 12464 KB Output is correct
9 Correct 348 ms 14208 KB Output is correct
10 Correct 259 ms 14128 KB Output is correct
11 Correct 301 ms 14112 KB Output is correct
12 Correct 119 ms 5056 KB Output is correct
13 Correct 293 ms 15000 KB Output is correct
14 Correct 415 ms 19248 KB Output is correct
15 Correct 403 ms 17344 KB Output is correct
16 Correct 404 ms 16816 KB Output is correct
17 Correct 239 ms 14384 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 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 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 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 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 332 KB Output is correct
16 Correct 3 ms 308 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 312 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 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 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 32 ms 1840 KB Output is correct
12 Correct 66 ms 3232 KB Output is correct
13 Correct 239 ms 6460 KB Output is correct
14 Correct 416 ms 12436 KB Output is correct
15 Correct 400 ms 12464 KB Output is correct
16 Correct 348 ms 14208 KB Output is correct
17 Correct 259 ms 14128 KB Output is correct
18 Correct 301 ms 14112 KB Output is correct
19 Correct 119 ms 5056 KB Output is correct
20 Correct 293 ms 15000 KB Output is correct
21 Correct 415 ms 19248 KB Output is correct
22 Correct 403 ms 17344 KB Output is correct
23 Correct 404 ms 16816 KB Output is correct
24 Correct 239 ms 14384 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 3 ms 332 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 3 ms 332 KB Output is correct
29 Correct 3 ms 308 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 110 ms 5084 KB Output is correct
34 Correct 255 ms 14968 KB Output is correct
35 Correct 432 ms 19348 KB Output is correct
36 Correct 353 ms 16816 KB Output is correct
37 Correct 387 ms 17472 KB Output is correct
38 Correct 419 ms 19376 KB Output is correct
39 Correct 284 ms 15536 KB Output is correct
40 Correct 271 ms 15000 KB Output is correct
41 Correct 246 ms 14384 KB Output is correct
42 Correct 251 ms 14412 KB Output is correct
43 Correct 246 ms 14416 KB Output is correct
44 Correct 242 ms 14400 KB Output is correct
45 Correct 463 ms 19248 KB Output is correct
46 Correct 265 ms 14892 KB Output is correct
47 Correct 239 ms 14312 KB Output is correct