#pragma GCC optimize ("O3")
#pragma GCC target ("avx,avx2")
#include <iostream>
using namespace std;
typedef long long ll;
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define int ll
const int N = 2e5;
const int INF = 1e9;
struct rudina {
int x, g, d;
} a[N];
int n, ans;
main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
fo(i, 1, n, 1) {
cin >> a[i].x >> a[i].g >> a[i].d;
//pref[i] = pref[i - 1] + a[i].g;
}
fo(i, 1, n, 1) {
int power = 0, gold = 0, ansGold = 0;
fo(j, i, n, 1) {
power += a[j].d;
gold += a[j].g;
if(power >= a[j].x - a[i].x) {
ansGold = gold;
}
}
ans = max(ans, ansGold);
}
cout << ans;
return 0;
}
Compilation message
divide.cpp:22:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main () {
^
# |
결과 |
실행 시간 |
메모리 |
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 |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 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 |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
444 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
22 ms |
508 KB |
Output is correct |
12 |
Correct |
22 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
504 KB |
Output is correct |
2 |
Correct |
78 ms |
736 KB |
Output is correct |
3 |
Correct |
78 ms |
760 KB |
Output is correct |
4 |
Execution timed out |
1068 ms |
2552 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |