답안 #409179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409179 2021-05-20T10:02:42 Z Ronin13 금 캐기 (IZhO14_divide) C++14
17 / 100
6 ms 6604 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
using namespace std;

vector<int>x(200001),d(200001);
vector<ll>g(200001);
vector<int>t(800001,INT_MAX);

void update(int v,int l,int r,int val,int pos){
    if(l==r){
        t[v]=val;
        return;
    }
    int m=(l+r)/2;
    if(pos<=m)update(2*v,l,m,val,pos);
    if(pos>m)update(2*v+1,m+1,r,val,pos);
    t[v]=min(t[2*v],t[2*v+1]);
}

int get(int v,int l,int r,int val){
    if(l==r){
        return l;
    }
    int m=(l+r)/2;
    if(t[2*v]<=val)return get(2*v,l,m,val);
    if(t[2*v+1]<=val)return get(2*v+1,m+1,r,val);
    return -1;
}

void solve(){
    int n;cin>>n;
    vector<ll>pref(n+1);
    pref[0]=0;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>g[i]>>d[i];
        d[i]+=d[i-1];
        pref[i]=pref[i-1]+g[i];
    }
    ll mx=0;
    for(int i=1;i<=n;i++){
        update(1,1,n,d[i-1]-x[i],i);
        int ind=get(1,1,n,d[i]-x[i]);

        mx=max(mx,pref[i]-pref[ind-1]);
    }
    cout<<mx;
}

int main(){
    solve();
}


# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 4 ms 6476 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 4 ms 6476 KB Output is correct
5 Correct 4 ms 6572 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6528 KB Output is correct
8 Correct 4 ms 6476 KB Output is correct
9 Correct 4 ms 6476 KB Output is correct
10 Correct 4 ms 6504 KB Output is correct
11 Correct 4 ms 6476 KB Output is correct
12 Correct 5 ms 6476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 4 ms 6476 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 4 ms 6476 KB Output is correct
5 Correct 4 ms 6572 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6528 KB Output is correct
8 Correct 4 ms 6476 KB Output is correct
9 Correct 4 ms 6476 KB Output is correct
10 Correct 4 ms 6504 KB Output is correct
11 Correct 4 ms 6476 KB Output is correct
12 Correct 5 ms 6476 KB Output is correct
13 Correct 4 ms 6476 KB Output is correct
14 Correct 5 ms 6476 KB Output is correct
15 Correct 4 ms 6580 KB Output is correct
16 Correct 5 ms 6476 KB Output is correct
17 Correct 6 ms 6588 KB Output is correct
18 Incorrect 6 ms 6604 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6476 KB Output is correct
2 Correct 4 ms 6476 KB Output is correct
3 Correct 5 ms 6476 KB Output is correct
4 Correct 4 ms 6476 KB Output is correct
5 Correct 4 ms 6572 KB Output is correct
6 Correct 4 ms 6476 KB Output is correct
7 Correct 4 ms 6528 KB Output is correct
8 Correct 4 ms 6476 KB Output is correct
9 Correct 4 ms 6476 KB Output is correct
10 Correct 4 ms 6504 KB Output is correct
11 Correct 4 ms 6476 KB Output is correct
12 Correct 5 ms 6476 KB Output is correct
13 Correct 4 ms 6476 KB Output is correct
14 Correct 5 ms 6476 KB Output is correct
15 Correct 4 ms 6580 KB Output is correct
16 Correct 5 ms 6476 KB Output is correct
17 Correct 6 ms 6588 KB Output is correct
18 Incorrect 6 ms 6604 KB Output isn't correct
19 Halted 0 ms 0 KB -