#include <bits/stdc++.h>
#define file ""
#define all(x) x.begin(), x.end()
#define sc second
#define fr first
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll inf = 1e18 + 5;
const ll mod = 1e9 + 7;
const int N = 1e5 + 5;
int dx[] = {+1, 0, -1, 0};
int dy[] = {0, +1, 0, -1};
struct line {
int x;
int d;
int g;
};
vector<line> a(N);
ll dp[N];
int main() {
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
srand(time(nullptr));
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i].x >> a[i].g >> a[i].d;
for (int i = 1; i <= n; i++) {
ll sum_d = 0;
ll sum_g = 0;
ll len;
for (int j = i; j >= 1; j--) {
sum_g += a[j].g;
sum_d += a[j].d;
len = a[i].x - a[j].x;
if (sum_d >= len) {
//cerr << j << " " << i << endl;
dp[i] = max(dp[i], sum_g);
}
}
}
cout << *max_element(dp + 1, dp + 1 + n);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1516 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
1 ms |
1516 KB |
Output is correct |
4 |
Correct |
1 ms |
1516 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1516 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
1516 KB |
Output is correct |
11 |
Correct |
1 ms |
1516 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1516 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
1 ms |
1516 KB |
Output is correct |
4 |
Correct |
1 ms |
1516 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1516 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
1516 KB |
Output is correct |
11 |
Correct |
1 ms |
1516 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
1 ms |
1516 KB |
Output is correct |
15 |
Correct |
2 ms |
1516 KB |
Output is correct |
16 |
Correct |
2 ms |
1536 KB |
Output is correct |
17 |
Correct |
2 ms |
1516 KB |
Output is correct |
18 |
Correct |
5 ms |
1516 KB |
Output is correct |
19 |
Correct |
3 ms |
1516 KB |
Output is correct |
20 |
Correct |
4 ms |
1516 KB |
Output is correct |
21 |
Correct |
3 ms |
1516 KB |
Output is correct |
22 |
Correct |
4 ms |
1516 KB |
Output is correct |
23 |
Correct |
17 ms |
1644 KB |
Output is correct |
24 |
Correct |
17 ms |
1644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1516 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
1 ms |
1516 KB |
Output is correct |
4 |
Correct |
1 ms |
1516 KB |
Output is correct |
5 |
Correct |
1 ms |
1536 KB |
Output is correct |
6 |
Correct |
1 ms |
1516 KB |
Output is correct |
7 |
Correct |
1 ms |
1516 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
1516 KB |
Output is correct |
11 |
Correct |
1 ms |
1516 KB |
Output is correct |
12 |
Correct |
1 ms |
1516 KB |
Output is correct |
13 |
Correct |
1 ms |
1516 KB |
Output is correct |
14 |
Correct |
1 ms |
1516 KB |
Output is correct |
15 |
Correct |
2 ms |
1516 KB |
Output is correct |
16 |
Correct |
2 ms |
1536 KB |
Output is correct |
17 |
Correct |
2 ms |
1516 KB |
Output is correct |
18 |
Correct |
5 ms |
1516 KB |
Output is correct |
19 |
Correct |
3 ms |
1516 KB |
Output is correct |
20 |
Correct |
4 ms |
1516 KB |
Output is correct |
21 |
Correct |
3 ms |
1516 KB |
Output is correct |
22 |
Correct |
4 ms |
1516 KB |
Output is correct |
23 |
Correct |
17 ms |
1644 KB |
Output is correct |
24 |
Correct |
17 ms |
1644 KB |
Output is correct |
25 |
Correct |
50 ms |
1644 KB |
Output is correct |
26 |
Correct |
193 ms |
1644 KB |
Output is correct |
27 |
Correct |
192 ms |
1772 KB |
Output is correct |
28 |
Execution timed out |
1086 ms |
2796 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |