Submission #237788

# Submission time Handle Problem Language Result Execution time Memory
237788 2020-06-08T18:35:07 Z ant101 Art Exhibition (JOI18_art) C++14
0 / 100
5 ms 384 KB
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <assert.h>
#include <limits>
#include <cstdio>
using namespace std;

//#define RDEBUG 1
#ifdef RDEBUG
#define D(x) x
#else
#define D(x)
#endif
#define inf 0x7fffffff
#define MOD 1000000007

typedef long long ll;


ll add(ll a, ll b) {
    a += b;
    if(a >= MOD) {
        a -= MOD;
    }
    return a;
}
ll sub(ll a, ll b) {
    a -= b;
    if(a < 0) {
        a += MOD;
    }
    return a;
}

ll mul(ll a, ll b) {
    return (a * b)%MOD;
}

void add_self(ll& a, ll b) {
    a = add(a, b);
}
void sub_self(ll& a, ll b) {
    a = sub(a, b);
}
void mul_self(ll& a, ll b) {
    a = mul(a, b);
}


const ll MAXN = 500010;

pair<ll, ll> art[MAXN];
ll N;
ll pref[MAXN];

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for (ll i = 1; i<=N; i++) {
        cin >> art[i].first >> art[i].second;
    }
    sort(art+1, art+N+1);
    for (ll i = 1; i<=N; i++) {
        pref[i] = pref[i-1]+art[i].second;
    }
    ll ans = 0;
    ll bestpainting = -1e13;
    for (ll i = N; i>=1; i--) {
        bestpainting = max(bestpainting, pref[i]-art[i].first);
        ans = max(ans, bestpainting+art[i].first-pref[i-1]);
    }
    cout << ans << "\n";
    return 0;
}




# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -