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 ll long long
using namespace std;
const int N=1e5+5;
int n,a,b,x;
ll ans;
typedef struct{
int x, gold , energy;
}camp;
vector<camp> v;
//<ll> g(N),d(N);
map <int, ll> g, d;
main(){
cin>>n;
for(int i=0; i<n; i++){
cin>>x>>a>>b;
v.push_back({x,a,b});
}
g[0]=v[0].gold; d[0]=v[0].energy;
for(int i=1; i<n; i++){
g[i]=g[i-1]+v[i].gold;
d[i]=d[i-1]+v[i].energy;
}
a=0;
for(int i=0; i<n; i++){
b=i;
if(v[b].x-v[a].x<= d[b]-d[a-1]){
//cout<<a<<" "<<b<<endl;
ans=max(ans, g[b]-g[a-1]);
continue;
}
while(v[b].x-v[a].x>d[b]-d[a-1] && a<=b){
a++;
}
i--;
}
cout<<ans<<endl;
}
Compilation message (stderr)
divide.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
13 | 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... |