#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define OK puts("OK");
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define int long long
#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()
#define rep(i,n) for (i=0;i<(n);++i)
#define rep1(i,n) for (i=1;i<=(n);++i)
#define ret return
#define nemeshay ios::sync_with_stdio(0),cin.tie(0);
const int N=1e6+12,INF=1e9+7;
int q[N],a[N],b[N],e[N],g[N],x[N];
main(){
nemeshay
int n,i,j,k,ans=0;
cin>>n;
rep1(i,n){
cin>>x[i]>>g[i]>>e[i];
ans=max(ans,g[i]);
a[i]=a[i-1]+e[i];
b[i]=b[i-1]+g[i];
}
for (i=1;i<=n;++i){
for (j=n;j>=i;--j){
if (ans>=b[j]-b[i-1])break;
int z=x[j]-x[i],c=a[j]-a[i-1];
if (z<=c){
ans=b[j]-b[i-1];
}
}
}
cout <<ans;
}
Compilation message
divide.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
divide.cpp: In function 'int main()':
divide.cpp:21:15: warning: unused variable 'k' [-Wunused-variable]
int n,i,j,k,ans=0;
^
# |
Verdict |
Execution time |
Memory |
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 |
384 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 |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
388 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 |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
480 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
436 KB |
Output is correct |
9 |
Correct |
4 ms |
396 KB |
Output is correct |
10 |
Correct |
5 ms |
532 KB |
Output is correct |
11 |
Correct |
21 ms |
632 KB |
Output is correct |
12 |
Correct |
21 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
632 KB |
Output is correct |
2 |
Correct |
5 ms |
920 KB |
Output is correct |
3 |
Correct |
6 ms |
992 KB |
Output is correct |
4 |
Correct |
20 ms |
3320 KB |
Output is correct |
5 |
Correct |
23 ms |
3576 KB |
Output is correct |
6 |
Correct |
47 ms |
7228 KB |
Output is correct |
7 |
Correct |
35 ms |
5980 KB |
Output is correct |
8 |
Correct |
36 ms |
6136 KB |
Output is correct |
9 |
Correct |
35 ms |
5844 KB |
Output is correct |
10 |
Execution timed out |
1063 ms |
5892 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |