Submission #1115227

# Submission time Handle Problem Language Result Execution time Memory
1115227 2024-11-20T08:57:19 Z staszic_ojuz Art Exhibition (JOI18_art) C++17
0 / 100
1 ms 336 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n;
    cin>>n;
    vector<pair<long long, long long>> vect(n);
    for (long long i=0;i<n;i++) cin>>vect[i].first>>vect[i].second;
    sort(vect.begin(), vect.end());
    long long s=0, e=0, sum=vect[0].second, best=vect[0].second;
    while (e<n){
        if (s==e){
            e++;
            if (e==n) break;
            sum+=vect[e].second;
            if (best<sum-vect[e].first+vect[s].first) best=sum-vect[e].first+vect[s].first;
            continue;
        }
        if (vect[s].first>vect[s].first+vect[s].second){
            s++;
            sum-=vect[s-1].second;
            if (best<sum-vect[e].first+vect[s].first) best=sum-vect[e].first+vect[s].first;
            continue;
        }
        e++;
        if (e==n) break;
        sum+=vect[e].second;
        if (best<sum-vect[e].first+vect[s].first) best=sum-vect[e].first+vect[s].first;
    }
    cout<<best<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -