제출 #85960

#제출 시각아이디문제언어결과실행 시간메모리
85960Nordway금 캐기 (IZhO14_divide)C++14
17 / 100
162 ms18124 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...