Submission #41074

# Submission time Handle Problem Language Result Execution time Memory
41074 2018-02-12T12:18:30 Z zscoder Art Exhibition (JOI18_art) C++14
100 / 100
259 ms 16500 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[511111];
ll b[511111];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	vector<pair<ll,ll> > vec;
	for(int i=0;i<n;i++)
	{
		ll x,y; cin>>x>>y;
		vec.pb(mp(x,y));
	}
	sort(vec.begin(),vec.end());
	for(int i=1;i<=n;i++)
	{
		a[i] = vec[i-1].fi;
		b[i] = vec[i-1].se;
	}
	for(int i=1;i<=n;i++)
	{
		b[i]+=b[i-1];
	}
	ll mini = b[0] - a[1];
	ll ans = 0;
	for(int i=1;i<=n;i++)
	{
		ans = max(ans, b[i]-a[i]-mini);
		if(i<n) mini=min(mini,b[i]-a[i+1]);
	}
	cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 660 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 1 ms 688 KB Output is correct
11 Correct 1 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 660 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 1 ms 688 KB Output is correct
11 Correct 1 ms 688 KB Output is correct
12 Correct 2 ms 688 KB Output is correct
13 Correct 2 ms 688 KB Output is correct
14 Correct 2 ms 688 KB Output is correct
15 Correct 2 ms 688 KB Output is correct
16 Correct 2 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 1 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 1 ms 688 KB Output is correct
21 Correct 1 ms 688 KB Output is correct
22 Correct 1 ms 688 KB Output is correct
23 Correct 1 ms 688 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 688 KB Output is correct
26 Correct 2 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 660 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 1 ms 688 KB Output is correct
11 Correct 1 ms 688 KB Output is correct
12 Correct 2 ms 688 KB Output is correct
13 Correct 2 ms 688 KB Output is correct
14 Correct 2 ms 688 KB Output is correct
15 Correct 2 ms 688 KB Output is correct
16 Correct 2 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 1 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 1 ms 688 KB Output is correct
21 Correct 1 ms 688 KB Output is correct
22 Correct 1 ms 688 KB Output is correct
23 Correct 1 ms 688 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 688 KB Output is correct
26 Correct 2 ms 688 KB Output is correct
27 Correct 4 ms 876 KB Output is correct
28 Correct 4 ms 876 KB Output is correct
29 Correct 5 ms 876 KB Output is correct
30 Correct 3 ms 928 KB Output is correct
31 Correct 4 ms 928 KB Output is correct
32 Correct 3 ms 928 KB Output is correct
33 Correct 5 ms 928 KB Output is correct
34 Correct 5 ms 928 KB Output is correct
35 Correct 4 ms 948 KB Output is correct
36 Correct 4 ms 948 KB Output is correct
37 Correct 3 ms 948 KB Output is correct
38 Correct 4 ms 948 KB Output is correct
39 Correct 4 ms 948 KB Output is correct
40 Correct 5 ms 948 KB Output is correct
41 Correct 4 ms 948 KB Output is correct
42 Correct 5 ms 948 KB Output is correct
43 Correct 4 ms 948 KB Output is correct
44 Correct 3 ms 948 KB Output is correct
45 Correct 5 ms 948 KB Output is correct
46 Correct 3 ms 948 KB Output is correct
47 Correct 3 ms 948 KB Output is correct
48 Correct 3 ms 948 KB Output is correct
49 Correct 5 ms 948 KB Output is correct
50 Correct 3 ms 948 KB Output is correct
51 Correct 3 ms 948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 476 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 1 ms 476 KB Output is correct
7 Correct 1 ms 660 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 1 ms 688 KB Output is correct
11 Correct 1 ms 688 KB Output is correct
12 Correct 2 ms 688 KB Output is correct
13 Correct 2 ms 688 KB Output is correct
14 Correct 2 ms 688 KB Output is correct
15 Correct 2 ms 688 KB Output is correct
16 Correct 2 ms 688 KB Output is correct
17 Correct 2 ms 688 KB Output is correct
18 Correct 1 ms 688 KB Output is correct
19 Correct 2 ms 688 KB Output is correct
20 Correct 1 ms 688 KB Output is correct
21 Correct 1 ms 688 KB Output is correct
22 Correct 1 ms 688 KB Output is correct
23 Correct 1 ms 688 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 688 KB Output is correct
26 Correct 2 ms 688 KB Output is correct
27 Correct 4 ms 876 KB Output is correct
28 Correct 4 ms 876 KB Output is correct
29 Correct 5 ms 876 KB Output is correct
30 Correct 3 ms 928 KB Output is correct
31 Correct 4 ms 928 KB Output is correct
32 Correct 3 ms 928 KB Output is correct
33 Correct 5 ms 928 KB Output is correct
34 Correct 5 ms 928 KB Output is correct
35 Correct 4 ms 948 KB Output is correct
36 Correct 4 ms 948 KB Output is correct
37 Correct 3 ms 948 KB Output is correct
38 Correct 4 ms 948 KB Output is correct
39 Correct 4 ms 948 KB Output is correct
40 Correct 5 ms 948 KB Output is correct
41 Correct 4 ms 948 KB Output is correct
42 Correct 5 ms 948 KB Output is correct
43 Correct 4 ms 948 KB Output is correct
44 Correct 3 ms 948 KB Output is correct
45 Correct 5 ms 948 KB Output is correct
46 Correct 3 ms 948 KB Output is correct
47 Correct 3 ms 948 KB Output is correct
48 Correct 3 ms 948 KB Output is correct
49 Correct 5 ms 948 KB Output is correct
50 Correct 3 ms 948 KB Output is correct
51 Correct 3 ms 948 KB Output is correct
52 Correct 208 ms 16380 KB Output is correct
53 Correct 208 ms 16396 KB Output is correct
54 Correct 208 ms 16424 KB Output is correct
55 Correct 201 ms 16452 KB Output is correct
56 Correct 202 ms 16452 KB Output is correct
57 Correct 210 ms 16452 KB Output is correct
58 Correct 207 ms 16488 KB Output is correct
59 Correct 212 ms 16488 KB Output is correct
60 Correct 210 ms 16500 KB Output is correct
61 Correct 205 ms 16500 KB Output is correct
62 Correct 210 ms 16500 KB Output is correct
63 Correct 226 ms 16500 KB Output is correct
64 Correct 217 ms 16500 KB Output is correct
65 Correct 219 ms 16500 KB Output is correct
66 Correct 200 ms 16500 KB Output is correct
67 Correct 259 ms 16500 KB Output is correct
68 Correct 227 ms 16500 KB Output is correct