Submission #229527

# Submission time Handle Problem Language Result Execution time Memory
229527 2020-05-04T22:49:01 Z nickmet2004 Art Exhibition (JOI18_art) C++11
0 / 100
5 ms 384 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second

using namespace std;

const int N = 5e5 + 5;

int n;
pair<ll , ll> p[N];
long long pr[N];

int main (){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> p[i].f >> p[i].s;
    sort(p , p + n);
    for(int i = n - 1; i >= 0; --i){
        pr[i] = pr[i + 1] + p[i].s;
    }
    long long MN = 1e18;
    long long MX = -1e18;
    for(int i = n - 2; i >= 0; --i){
        MN = min(MN , pr[i + 1] + p[i].f);
        MX = max(MX , pr[i] - MN + p[i].f);
    }
    cout << MX << endl;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -