Submission #106875

# Submission time Handle Problem Language Result Execution time Memory
106875 2019-04-20T19:41:27 Z FiloSanza Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    int N;
    cin >> N;
    vector<pair<long long, int>> v(N);

    for(auto &i : v) cin >> i.first >> i.second;
    sort(v.begin(), v.end());

    long long x, y, sum = 0, ans;
    for(auto i : v) sum += i.second;

    ans = sum - (v.back().first - v.front().first);
    int lo = 0, hi = N-1;
    
    while(lo < hi){
        x = sum - v[lo].second - (v[hi].first - v[lo+1].first); 
        y = sum - v[hi].second - (v[hi-1].first - v[lo].first); 
        
        if(x > y){
            sum -= v[lo].second;
            lo++;
            ans = max(ans, x);
        }
        else{
            sum -= v[hi].second;
            hi--;
            ans = max(ans, y);
        }
    }

    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -