# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68434 | yusufake | Divide and conquer (IZhO14_divide) | C++98 | 88 ms | 19820 KiB |
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>
using namespace std;
typedef long long ll;
const int N = 2e5;
ll F[N+N],X[N],G[N],D[N],T[N+N],t,n,i,j,ans;
ll qry(int x){
ll t = 1LL << 55;
for(; x ; x -= x&-x)
t = min(t , F[x]);
return t;
}
void up(int x, ll a){
for(; x <= t ; x += x&-x)
F[x] = min(F[x] , a);
}
int main(){
scanf("%lld",&n);
for(i=1;i<=n;i++){
scanf("%lld%lld%lld",&X[i],&G[i],&D[i]);
G[i] += G[i-1];
D[i] += D[i-1];
T[++t] = D[i]-X[i];
T[++t] = D[i-1]-X[i];
}
sort(T+1 , T+t+1);
memset(F , 127 , sizeof F);
for(i=1;i<=n;i++){
j = lower_bound(T+1 , T+t+1 , D[i-1]-X[i]) - T;
up(j,G[i-1]);
j = lower_bound(T+1 , T+t+1 , D[i]-X[i]) - T;
ans = max(ans , G[i] - qry(j));
}
printf("%lld", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |