이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |