Submission #145713

# Submission time Handle Problem Language Result Execution time Memory
145713 2019-08-20T20:33:04 Z mat_v Art Exhibition (JOI18_art) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))
#define maxn 500005

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

template<class T>
void print(const T niz[], const int siz)
{
    for(int i=0;i<siz;i++)
        cout << niz[i] << " ";
    cout << endl;
}

int n;
pii niz[maxn];
ll sol = -1e9;
ll mini;
bool cmp(pii a, pii b){
    return a.yy < b.yy;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    ff(i,1,n){
        int a, b;
        cin >> a >> b;
        niz[i] = {b,a};
    }
    sort(niz + 1, niz + n + 1,cmp);
    mini = -niz[1].yy;
    ll sum = 0;
    ff(i,1,n){
        sum += niz[i].xx;
        sol = max(sol, sum - mini - niz[i].yy);
        mini = min(mini, sum - niz[i+1].yy);
    }
    cout << sol << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -