#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0)
#define FILE "divide"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int mod=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const ld pi=acos(-1);
const int N=1e5+5;
ll g[N],x[N],d[N],sum[N],p[N];
int main(){
/*freopen(FILE".in","r",stdin);
freopen(FILE".out","w",stdout);*/
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>x[i]>>g[i]>>d[i];
p[i]=p[i-1]+d[i];
sum[i]=sum[i-1]+g[i];
}
ll res=0;
for(int i=1;i<=n;i++){
int l=i,r=n;
int ans=0;
while(l<=r){
int mid=(l+r)/2;
if(p[mid]-p[i-1]>=x[mid]-x[i])ans=mid,l=mid+1;
else r=mid-1;
}
res=max(res,sum[ans]-sum[i-1]);
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
624 KB |
Output is correct |
5 |
Correct |
2 ms |
668 KB |
Output is correct |
6 |
Correct |
3 ms |
672 KB |
Output is correct |
7 |
Correct |
3 ms |
676 KB |
Output is correct |
8 |
Correct |
2 ms |
808 KB |
Output is correct |
9 |
Correct |
2 ms |
808 KB |
Output is correct |
10 |
Correct |
2 ms |
808 KB |
Output is correct |
11 |
Correct |
2 ms |
808 KB |
Output is correct |
12 |
Correct |
3 ms |
808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
960 KB |
Output is correct |
2 |
Correct |
2 ms |
960 KB |
Output is correct |
3 |
Incorrect |
3 ms |
972 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1160 KB |
Output is correct |
2 |
Correct |
11 ms |
1496 KB |
Output is correct |
3 |
Correct |
13 ms |
1680 KB |
Output is correct |
4 |
Correct |
67 ms |
4364 KB |
Output is correct |
5 |
Correct |
79 ms |
5708 KB |
Output is correct |
6 |
Correct |
162 ms |
10884 KB |
Output is correct |
7 |
Correct |
117 ms |
12504 KB |
Output is correct |
8 |
Correct |
140 ms |
14612 KB |
Output is correct |
9 |
Correct |
151 ms |
16224 KB |
Output is correct |
10 |
Incorrect |
138 ms |
18124 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |