Submission #206276

# Submission time Handle Problem Language Result Execution time Memory
206276 2020-03-02T23:11:50 Z lucky_c25 Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 380 KB
#include<bits/stdc++.h>
#define maxn 500010
using namespace std;

long long int maxx[maxn],p[maxn];
pair<long long int,int> s[maxn];

int main()
{
    int n; cin>>n;
    for(int i = 1;i<=n;i++) cin>>s[i].first>>s[i].second;
    sort(s+1,s+n+1);

    long long int suma = 0;
    for(int i = 0;i<n;i++){
        suma+=s[i].second;
        p[i] = suma;
    }

    for(int i = 1;i<=n;i++){
        maxx[i] = max(maxx[i-1],s[i].first-p[i-1]);
    }

    long long int res = 0;
    for(int i = 1;i<=n;i++){
        res = max(res,p[i]-s[i].first+maxx[i]);
    }
    cout<<res;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 380 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -