#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
struct camp {
int x,g,d;
};
vector<camp> v;
const int N=1e6+7;
ll p[N];
ll sum[N];
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n; cin>>n;
v.resize(n+1);
for(int i=1; i<=n; i++) {
cin>>v[i].x>>v[i].g>>v[i].d;
p[i]=p[i-1]+v[i].d;
sum[i]=sum[i-1]+v[i].g;
}
ll ans=0;
for(int i=1; i<=n; i++) {
for(int j=i; j<=n; j++) {
if(v[j].x-v[i].x<=p[j]-p[i-1]) {
// cout<<i<<" "<<j<<endl;
ans=max(ans,sum[j]-sum[i-1]);
}
}
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
512 KB |
Output is correct |
11 |
Correct |
16 ms |
640 KB |
Output is correct |
12 |
Correct |
15 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
512 KB |
Output is correct |
2 |
Correct |
77 ms |
768 KB |
Output is correct |
3 |
Correct |
85 ms |
896 KB |
Output is correct |
4 |
Execution timed out |
1070 ms |
2816 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |