Submission #238857

# Submission time Handle Problem Language Result Execution time Memory
238857 2020-06-13T09:37:56 Z michao Art Exhibition (JOI18_art) C++14
100 / 100
233 ms 20892 KB
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
using namespace std;
const int MAX=500005;
const int inf=1e18+9;
pii tab[MAX];
int pref[MAX];
int32_t main()
{
  BOOST;
  int n;
  cin>>n;
  for (int i=1;i<=n;i++)cin>>tab[i].st>>tab[i].nd;
  sort(tab+1,tab+n+1);
  int ans=0,maxi=0,sum=0;
  for (int i=1;i<=n;i++)
  {
  	sum+=tab[i].nd;
  	pref[i]=sum;
  	maxi=max(maxi,tab[i].st-pref[i-1]);
  	int akt=sum-tab[i].st+maxi;
  	ans=max(ans,akt);
  	//cout<<"TERAZ "<<ans<<" "<<i<<" "<<"\n";
  }
  
  cout<<ans;
  return 0;
}

Compilation message

art.cpp:4:1: warning: multi-line comment [-Wcomment]
 //   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
 ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 7 ms 512 KB Output is correct
31 Correct 7 ms 512 KB Output is correct
32 Correct 7 ms 512 KB Output is correct
33 Correct 7 ms 512 KB Output is correct
34 Correct 7 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 7 ms 512 KB Output is correct
37 Correct 7 ms 512 KB Output is correct
38 Correct 7 ms 512 KB Output is correct
39 Correct 6 ms 512 KB Output is correct
40 Correct 7 ms 512 KB Output is correct
41 Correct 7 ms 512 KB Output is correct
42 Correct 6 ms 512 KB Output is correct
43 Correct 7 ms 512 KB Output is correct
44 Correct 7 ms 512 KB Output is correct
45 Correct 7 ms 512 KB Output is correct
46 Correct 6 ms 512 KB Output is correct
47 Correct 7 ms 512 KB Output is correct
48 Correct 6 ms 512 KB Output is correct
49 Correct 6 ms 512 KB Output is correct
50 Correct 6 ms 512 KB Output is correct
51 Correct 6 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 7 ms 512 KB Output is correct
31 Correct 7 ms 512 KB Output is correct
32 Correct 7 ms 512 KB Output is correct
33 Correct 7 ms 512 KB Output is correct
34 Correct 7 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 7 ms 512 KB Output is correct
37 Correct 7 ms 512 KB Output is correct
38 Correct 7 ms 512 KB Output is correct
39 Correct 6 ms 512 KB Output is correct
40 Correct 7 ms 512 KB Output is correct
41 Correct 7 ms 512 KB Output is correct
42 Correct 6 ms 512 KB Output is correct
43 Correct 7 ms 512 KB Output is correct
44 Correct 7 ms 512 KB Output is correct
45 Correct 7 ms 512 KB Output is correct
46 Correct 6 ms 512 KB Output is correct
47 Correct 7 ms 512 KB Output is correct
48 Correct 6 ms 512 KB Output is correct
49 Correct 6 ms 512 KB Output is correct
50 Correct 6 ms 512 KB Output is correct
51 Correct 6 ms 512 KB Output is correct
52 Correct 216 ms 20344 KB Output is correct
53 Correct 220 ms 20728 KB Output is correct
54 Correct 213 ms 20728 KB Output is correct
55 Correct 215 ms 20856 KB Output is correct
56 Correct 227 ms 20740 KB Output is correct
57 Correct 222 ms 20856 KB Output is correct
58 Correct 221 ms 20772 KB Output is correct
59 Correct 228 ms 20856 KB Output is correct
60 Correct 223 ms 20856 KB Output is correct
61 Correct 217 ms 20892 KB Output is correct
62 Correct 217 ms 20728 KB Output is correct
63 Correct 233 ms 20728 KB Output is correct
64 Correct 218 ms 20600 KB Output is correct
65 Correct 220 ms 20728 KB Output is correct
66 Correct 213 ms 20600 KB Output is correct
67 Correct 220 ms 20600 KB Output is correct
68 Correct 232 ms 20600 KB Output is correct