답안 #681483

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681483 2023-01-13T07:04:48 Z boykut 금 캐기 (IZhO14_divide) C++14
100 / 100
34 ms 6732 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 100100;
int x[N], g[N], e[N];
long long pg[N], pe[N], prefmin[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  prefmin[0] = LLONG_MAX;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> g[i] >> e[i];
    pg[i] = pg[i-1] + g[i];
    pe[i] = pe[i-1] + e[i];
    prefmin[i] = min(prefmin[i-1], pe[i-1]-x[i]);
  }
  
  long long answer = 0;
  for (int r = 1; r <= n; r++) {
    int A = 1, B = r;
    while (A < B) {
      int l = (A + B) >> 1;
      if (prefmin[l] <= pe[r]-x[r])
        B = l;
      else
        A = l + 1;
    }
    if (prefmin[B] <= pe[r]-x[r])
      answer = max(answer, pg[r]-pg[B-1]);
  }
  
  cout << answer;
  
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 396 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 392 KB Output is correct
21 Correct 1 ms 396 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 596 KB Output is correct
24 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 396 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 392 KB Output is correct
21 Correct 1 ms 396 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 596 KB Output is correct
24 Correct 2 ms 592 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 848 KB Output is correct
28 Correct 17 ms 3060 KB Output is correct
29 Correct 16 ms 3396 KB Output is correct
30 Correct 34 ms 6732 KB Output is correct
31 Correct 25 ms 5448 KB Output is correct
32 Correct 25 ms 5568 KB Output is correct
33 Correct 24 ms 5452 KB Output is correct
34 Correct 30 ms 5456 KB Output is correct
35 Correct 31 ms 5908 KB Output is correct
36 Correct 28 ms 6080 KB Output is correct