Submission #966860

# Submission time Handle Problem Language Result Execution time Memory
966860 2024-04-20T13:46:19 Z vjudge1 Art Exhibition (JOI18_art) C++11
0 / 100
1 ms 2392 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fi first
#define se second

ll N;
pll arr[500100];
ll psum[500100];
ll ans, maks;


int main() 
{
    cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> arr[i].fi >> arr[i].se;
    }
    sort(arr+1, arr+N+1);
    for(int i=1; i<=N; i++) {
        psum[i] = psum[i-1] + arr[i].se;
    }
    for(int i=N; i>=1; i--) {
        maks = max(maks, psum[i]-arr[i].fi);
        ans = max(ans, maks + arr[i].fi-psum[i-1]);
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -