Submission #1033827

# Submission time Handle Problem Language Result Execution time Memory
1033827 2024-07-25T06:46:41 Z coldbr3w Art Exhibition (JOI18_art) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
 
const ll N = 5e5 + 100;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 480;
ll n;
pll a[N];
ll ps[N];
void to_thic_cau(){
    cin >> n;
    for(int i = 1; i <= n;i++){
        cin >> a[i].F >> a[i].S;
    }
    sort(a + 1, a + n + 1);
    ll mx = -inf, res = -inf;
    for(int i = 1; i <= n;i++){
        ps[i] = ps[i-1] + a[i].S;
        res = max(res, ps[i] - a[i].F + mx);
        mx = max(mx, a[i].F - ps[i-1]);
    }
    cout << res << '\n';
}
 
signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll tc = 1;
    //cin >> tc;
    while(tc--) to_thic_cau();
}
# 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 -