Submission #48927

# Submission time Handle Problem Language Result Execution time Memory
48927 2018-05-20T04:46:22 Z faishol27 Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 248 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define PUB push_back

struct art{
    ll sz, val;
};

int N;
ll pref[500005];
vector<art> data;

bool comp(art a, art b){
    if(a.sz == b.sz) return a.val < b.val;
    return a.sz < b.sz;
}

int main(){
    cin >> N;
    data.PUB({0,0});
    for(int i=1;i<=N;i++){
        ll a, b;
        cin >> a >> b;
        data.PUB({a, b});
    }

    sort(data.begin(), data.end(), comp);

    for(int i=1;i<=N;i++) pref[i] = pref[i-1]+data[i].val;
    
    int l=1, r=N;
    ll sum_tmb = 0, sum_krg = 0;

    for(int i=1;i<r;i++){
        sum_krg += data[i].val;
        sum_tmb += data[i+1].sz-data[i].sz;
        
        if(sum_krg < sum_tmb){
            l = i+1;
            sum_krg = 0;
            sum_tmb = 0;
        }
    }
    
    sum_tmb = 0; sum_krg = 0;
    for(int i=r;i>l;i--){
        sum_krg += data[i].val;
        sum_tmb += data[i].sz-data[i-1].sz;
        
        if(sum_krg < sum_tmb){
            r = i-1;
            sum_krg = 0;
            sum_tmb = 0;
        }
    }
    
    cout << (pref[r]-pref[l-1])-(data[r].sz - data[l].sz) << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -