This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, pair<int,int> >
#define x first
#define y second.first
#define z second.second
using namespace std;
int n;
pii a[100005];
main(){
cin>>n;
for(int k=1;k<=n;k++){
int a1,b,c;
cin>>a1>>b>>c;
a[k]={a1,{b,c}};
}
int l=1;
int ans=a[1].y,sc=a[1].z;
int pas=ans;
for(int r=1;r<=n;r++){
if(r!=1){
ans+=a[r].y;
sc+=a[r].z;
}
while(l<=r && sc<a[r].x-a[l].x){
ans-=a[l].y;
sc-=a[l].z;
l++;
}
pas=max(pas,ans);
}
cout<<pas;
return 0;
}
Compilation message (stderr)
divide.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |