Submission #972157

# Submission time Handle Problem Language Result Execution time Memory
972157 2024-04-30T07:54:46 Z Hectorungo_18 Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include <iostream>
#include <bits/stdc++.h>
#include <list>
#include <set>
#include <cstdio>

using namespace std;
#define int long long
#define f first
#define s second 


void solve(){
    int n;
    cin >> n;
    vector<pair<int, int>> v(n+1, {0, 0});

    for(int i = 1; i <= n; i++) cin >> v[i].f >> v[i].s;

    sort(v.begin(), v.end());


    vector<int> ps(n+1, 0);
    ps[1] = v[1].s;
    for(int i = 2; i <= n; i++){
        ps[i] = ps[i-1]+v[i].s;
        ps[i]+=v[i-1].f-v[i].f;
    }
    // cout << endl;
    int ans = ps[1];
    int mn = min(ps[1], (int) 0);
    for(int i = 2; i <= n; i++){
        if(ps[i]-mn > ans){
            ans = ps[i]-mn;
        }
        mn = min(mn, ps[i]);
    }

    cout << ans << endl;

}

signed main() {
    int t = 1;
    // cin >> t;
    while(t--) solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -