#include <bits/stdc++.h>
#define ll long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define int long long
using namespace std;
const int N = 5e3 + 3;
int n, x[N], d[N], g[N];
int pd[N], pg[N], ans;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for (int i = 1; i <= n; i++) {
cin>>x[i]>>g[i]>>d[i];
pd[i] = pd[i - 1] + d[i];
pg[i] = pg[i - 1] + g[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (pd[i] - pd[j - 1] >= x[i] - x[j]) {
ans = max(ans, pg[i] - pg[j - 1]);
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
392 KB |
Output is correct |
8 |
Correct |
3 ms |
380 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
504 KB |
Output is correct |
11 |
Correct |
15 ms |
612 KB |
Output is correct |
12 |
Correct |
16 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
632 KB |
Output is correct |
2 |
Runtime error |
5 ms |
1068 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |