#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int n, l, x[N], g[N], e[N];
ll de[N], dg[N], ans;
set < pair < ll, int > > st;
int main() {
// freopen("divide.in", "r", stdin);
// freopen("divide.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
cout << "\n";
for (int i = 1; i <= n; ++i) {
cin >> x[i] >> g[i] >> e[i];
dg[i] += dg[i - 1] + g[i];
de[i] += de[i - 1] + e[i];
}
for (int r = 1; r <= n; ++r) {
for (int l = 1; l <= r; ++l) {
if (x[r] - x[l] <= de[r] - de[l - 1] && dg[r] - dg[l - 1] > ans) {
ans = dg[r] - dg[l - 1];
break;
}
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4908 KB |
Output is correct |
2 |
Correct |
0 ms |
4908 KB |
Output is correct |
3 |
Correct |
0 ms |
4908 KB |
Output is correct |
4 |
Correct |
0 ms |
4908 KB |
Output is correct |
5 |
Correct |
0 ms |
4908 KB |
Output is correct |
6 |
Correct |
0 ms |
4908 KB |
Output is correct |
7 |
Correct |
0 ms |
4908 KB |
Output is correct |
8 |
Correct |
0 ms |
4908 KB |
Output is correct |
9 |
Correct |
0 ms |
4908 KB |
Output is correct |
10 |
Correct |
0 ms |
4908 KB |
Output is correct |
11 |
Correct |
0 ms |
4908 KB |
Output is correct |
12 |
Correct |
0 ms |
4908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4908 KB |
Output is correct |
2 |
Correct |
0 ms |
4908 KB |
Output is correct |
3 |
Correct |
0 ms |
4908 KB |
Output is correct |
4 |
Correct |
0 ms |
4908 KB |
Output is correct |
5 |
Correct |
0 ms |
4908 KB |
Output is correct |
6 |
Correct |
0 ms |
4908 KB |
Output is correct |
7 |
Correct |
0 ms |
4908 KB |
Output is correct |
8 |
Correct |
0 ms |
4908 KB |
Output is correct |
9 |
Correct |
0 ms |
4908 KB |
Output is correct |
10 |
Correct |
3 ms |
4908 KB |
Output is correct |
11 |
Correct |
16 ms |
4908 KB |
Output is correct |
12 |
Correct |
16 ms |
4908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4908 KB |
Output is correct |
2 |
Correct |
3 ms |
4908 KB |
Output is correct |
3 |
Correct |
6 ms |
4908 KB |
Output is correct |
4 |
Correct |
13 ms |
4908 KB |
Output is correct |
5 |
Correct |
13 ms |
4908 KB |
Output is correct |
6 |
Correct |
46 ms |
4908 KB |
Output is correct |
7 |
Correct |
26 ms |
4908 KB |
Output is correct |
8 |
Correct |
33 ms |
4908 KB |
Output is correct |
9 |
Correct |
29 ms |
4908 KB |
Output is correct |
10 |
Execution timed out |
1000 ms |
4908 KB |
Execution timed out |
11 |
Halted |
0 ms |
0 KB |
- |