# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66731 | 2018-08-12T07:52:43 Z | ekrem | Art Exhibition (JOI18_art) | C++ | 2 ms | 248 KB |
#include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define N 1000005 using namespace std; typedef long long ll; ll n, cvp, mn, mx, ans, bas = 1, son; pair < ll , ll > a[N], q[N]; bool cikar(){ ll yed = cvp; cvp += mx - mn; mn = q[bas + 1].st; cvp -= q[bas].nd; cvp -= mx - mn; if(cvp >= yed) return 1; cvp = yed; mn = q[bas].st; return 0; } ll sz(){return son - bas + 1;} void ekle(ll a, ll b){ cvp += mx - mn; mx = a; cvp += b; cvp -= mx - mn; q[++son] = mp(a, b); ans = max(ans, cvp); while(sz() >= 1) if(cikar()) bas++; else break; ans = max(ans, cvp); } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); scanf("%lld",&n); for(ll i = 1; i <= n; i++) scanf("%lld %lld",&a[i].st ,&a[i].nd); sort(a + 1, a + n + 1); mn = a[1].st; mx = a[1].st; cvp = a[1].nd; ans = cvp; for(ll i = 2; i <= n; i++) ekle(a[i].st, a[i].nd); printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |