답안 #561509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
561509 2022-05-13T03:30:13 Z gg123_pe 금 캐기 (IZhO14_divide) C++14
100 / 100
128 ms 11972 KB
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll; 
#define f(i,a,b) for(int i = a; i < b; i++)
const int N = 1e5 + 5; 
const ll inf = 1e17 + 100; 

int n; 
ll a[N], g[N], e[N], sg[N], se[N], ans; 

int main(){
    cin >> n;

    vector <pair<ll,pair<ll,ll>>> v; 

    f(i,1,n+1) {
        cin >> a[i] >> g[i] >> e[i]; 
        sg[i] = sg[i-1] + g[i]; 
        se[i] = se[i-1] + e[i]; 

        v.push_back({se[i] - a[i], {1, -sg[i]}}); 
        v.push_back({se[i-1] - a[i], {0, sg[i-1]}}); 
    }

    ll mini = inf; 
    sort(v.begin(), v.end()); 

    for(auto p: v){
        ll y = p.second.second; 

        if(y < 0){
            ans = max(ans, abs(y) - mini); 
        }
        else{
            mini = min(mini, y); 
        }
    }
    cout << ans << "\n"; 
    return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 312 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 308 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 312 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 308 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 552 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 7 ms 1044 KB Output is correct
24 Correct 6 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 312 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 308 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 552 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 7 ms 1044 KB Output is correct
24 Correct 6 ms 1000 KB Output is correct
25 Correct 5 ms 1044 KB Output is correct
26 Correct 8 ms 1616 KB Output is correct
27 Correct 10 ms 1744 KB Output is correct
28 Correct 53 ms 4940 KB Output is correct
29 Correct 57 ms 6032 KB Output is correct
30 Correct 128 ms 11972 KB Output is correct
31 Correct 85 ms 10664 KB Output is correct
32 Correct 97 ms 10860 KB Output is correct
33 Correct 95 ms 10620 KB Output is correct
34 Correct 89 ms 10656 KB Output is correct
35 Correct 101 ms 11156 KB Output is correct
36 Correct 117 ms 11280 KB Output is correct