답안 #908795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908795 2024-01-16T21:28:46 Z khachatur25 금 캐기 (IZhO14_divide) C++14
100 / 100
190 ms 6456 KB
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 7;

ll x[N], g[N], d[N], mx[N];

int main() {
    int n;cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> x[i] >> g[i] >> d[i];
        g[i] += g[i-1], d[i] += d[i-1];
    }
    ll l = 0, r = 1e15, ans = -1;
    while(l <= r) {
        ll mid = l + (r - l) / 2;
        ll ok = 0;
        for(int i = 1;i <= n;i++) {
            mx[i] = max(mx[i - 1], x[i]- d[i - 1]);
            ll _l = 0, _r = i - 1, pos = -1;
            while(_l <= _r) {
                ll _m = _l + (_r - _l) / 2;
                if(g[i] - g[_m] >= mid) pos = _m, _l = _m + 1;
                else _r = _m - 1;
            }
            if(pos == -1) continue;
            if(x[i] - d[i] <= mx[pos + 1]) {
                ok = 1;
                break;
            }
        }
        if(ok) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2492 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2524 KB Output is correct
17 Correct 3 ms 2512 KB Output is correct
18 Correct 3 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 2 ms 2544 KB Output is correct
22 Correct 3 ms 2396 KB Output is correct
23 Correct 8 ms 2652 KB Output is correct
24 Correct 8 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2492 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 2 ms 2524 KB Output is correct
17 Correct 3 ms 2512 KB Output is correct
18 Correct 3 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 2 ms 2544 KB Output is correct
22 Correct 3 ms 2396 KB Output is correct
23 Correct 8 ms 2652 KB Output is correct
24 Correct 8 ms 2652 KB Output is correct
25 Correct 6 ms 2396 KB Output is correct
26 Correct 11 ms 2652 KB Output is correct
27 Correct 13 ms 2652 KB Output is correct
28 Correct 69 ms 3932 KB Output is correct
29 Correct 75 ms 4152 KB Output is correct
30 Correct 159 ms 6456 KB Output is correct
31 Correct 137 ms 5268 KB Output is correct
32 Correct 139 ms 5160 KB Output is correct
33 Correct 142 ms 5180 KB Output is correct
34 Correct 172 ms 5172 KB Output is correct
35 Correct 183 ms 5608 KB Output is correct
36 Correct 190 ms 5996 KB Output is correct