#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;
}
if(ans==0)continue;
res=max(res,sum[ans]-sum[i-1]);
}
cout<<res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
464 KB |
Output is correct |
5 |
Correct |
2 ms |
464 KB |
Output is correct |
6 |
Correct |
3 ms |
464 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
2 ms |
464 KB |
Output is correct |
9 |
Correct |
2 ms |
528 KB |
Output is correct |
10 |
Correct |
2 ms |
528 KB |
Output is correct |
11 |
Correct |
2 ms |
552 KB |
Output is correct |
12 |
Correct |
2 ms |
680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
680 KB |
Output is correct |
2 |
Correct |
2 ms |
680 KB |
Output is correct |
3 |
Incorrect |
3 ms |
680 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
696 KB |
Output is correct |
2 |
Correct |
13 ms |
992 KB |
Output is correct |
3 |
Correct |
17 ms |
992 KB |
Output is correct |
4 |
Correct |
72 ms |
2564 KB |
Output is correct |
5 |
Correct |
84 ms |
2564 KB |
Output is correct |
6 |
Correct |
160 ms |
4456 KB |
Output is correct |
7 |
Correct |
115 ms |
4456 KB |
Output is correct |
8 |
Correct |
144 ms |
4456 KB |
Output is correct |
9 |
Correct |
115 ms |
4492 KB |
Output is correct |
10 |
Incorrect |
116 ms |
4508 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |