Submission #565829

# Submission time Handle Problem Language Result Execution time Memory
565829 2022-05-21T11:50:07 Z nots0fast Art Exhibition (JOI18_art) C++17
100 / 100
193 ms 8840 KB
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb push_back
#define mt make_tuple
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = 998244353;

void deal(){
	ll n;
      cin>>n;
      vector<pair<ll, ll> > arr;
      fori(n){
            ll ai, si;
            cin>>ai>>si;
            arr.pb(mp(ai, si));
      }
      sort(arr.begin(), arr.end());
      ll mx = -inf;
      ll pf = 0;
      ll ans = 0;
      for(auto& el : arr){
            ll vl = pf-el.ff;
            mx = max(mx, -vl);
            pf+=el.ss;
            vl = pf-el.ff;
            ans = max(ans, vl + mx);
      }
      cout<<ans;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    deal();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 280 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 280 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 572 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 3 ms 596 KB Output is correct
34 Correct 2 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 2 ms 596 KB Output is correct
37 Correct 3 ms 572 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 2 ms 588 KB Output is correct
40 Correct 3 ms 596 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 3 ms 596 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 3 ms 584 KB Output is correct
45 Correct 3 ms 596 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 2 ms 596 KB Output is correct
49 Correct 3 ms 596 KB Output is correct
50 Correct 2 ms 596 KB Output is correct
51 Correct 3 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 280 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 572 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 2 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 3 ms 596 KB Output is correct
34 Correct 2 ms 596 KB Output is correct
35 Correct 2 ms 596 KB Output is correct
36 Correct 2 ms 596 KB Output is correct
37 Correct 3 ms 572 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 2 ms 588 KB Output is correct
40 Correct 3 ms 596 KB Output is correct
41 Correct 2 ms 596 KB Output is correct
42 Correct 3 ms 596 KB Output is correct
43 Correct 2 ms 596 KB Output is correct
44 Correct 3 ms 584 KB Output is correct
45 Correct 3 ms 596 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 2 ms 596 KB Output is correct
49 Correct 3 ms 596 KB Output is correct
50 Correct 2 ms 596 KB Output is correct
51 Correct 3 ms 648 KB Output is correct
52 Correct 177 ms 8792 KB Output is correct
53 Correct 193 ms 8804 KB Output is correct
54 Correct 169 ms 8740 KB Output is correct
55 Correct 169 ms 8736 KB Output is correct
56 Correct 173 ms 8768 KB Output is correct
57 Correct 186 ms 8748 KB Output is correct
58 Correct 187 ms 8772 KB Output is correct
59 Correct 173 ms 8840 KB Output is correct
60 Correct 174 ms 8760 KB Output is correct
61 Correct 170 ms 8748 KB Output is correct
62 Correct 188 ms 8708 KB Output is correct
63 Correct 168 ms 8680 KB Output is correct
64 Correct 177 ms 8684 KB Output is correct
65 Correct 167 ms 8636 KB Output is correct
66 Correct 177 ms 8768 KB Output is correct
67 Correct 180 ms 8704 KB Output is correct
68 Correct 173 ms 8712 KB Output is correct