Submission #1118560

# Submission time Handle Problem Language Result Execution time Memory
1118560 2024-11-25T16:50:09 Z heey Art Exhibition (JOI18_art) C++14
0 / 100
1 ms 352 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<pair<int, int>> a;

    for(int i = 0; i < n; i++){
        int c, b; cin >> c >> b;
        a.emplace_back(c, b);
    }

    sort(a.begin(), a.end());
    int res = 0;
    int tsum = 0;
    int l = 0, r = 0;
    while(r < n){
        tsum += a[r].second;

        if(r != 0 && a[r-1].first - tsum - a[l].first > 0){
            l = r-1;
            tsum = a[l].second + a[r].second;
        }
        res = max(res, tsum - a[r].first + a[l].first);
        r++;
    }

    cout << res << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Halted 0 ms 0 KB -