Submission #91340

# Submission time Handle Problem Language Result Execution time Memory
91340 2018-12-27T07:47:43 Z aminra Art Exhibition (JOI18_art) C++14
100 / 100
215 ms 221016 KB
//tavakol bar khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = (int)5e5 + 7;
const int MOD = (int)1e9 + 7;
const int infint = (int)1e8 + 3;
const ll inf = (ll)1e18;
ll n, part[MAXN];
pair<ll, ll> P[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)	
		cin >> P[i].first >> P[i].second;
	sort(P, P + n);
	part[0] = P[0].second;
	for (int i = 1; i < n; i++)
		part[i] = part[i - 1] + P[i].second;


	ll ans = 0, mn = 0;
	for (int i = 0; i < n; i++)
	{
		if(i == 0)
			mn = -P[0].first;
		else
			mn = min(mn, part[i - 1] - P[i].first);
		ans = max(ans, part[i] - P[i].first - mn);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 696 KB Output is correct
15 Correct 2 ms 696 KB Output is correct
16 Correct 2 ms 696 KB Output is correct
17 Correct 2 ms 696 KB Output is correct
18 Correct 2 ms 696 KB Output is correct
19 Correct 2 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 2 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 696 KB Output is correct
15 Correct 2 ms 696 KB Output is correct
16 Correct 2 ms 696 KB Output is correct
17 Correct 2 ms 696 KB Output is correct
18 Correct 2 ms 696 KB Output is correct
19 Correct 2 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 2 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 696 KB Output is correct
27 Correct 3 ms 764 KB Output is correct
28 Correct 4 ms 764 KB Output is correct
29 Correct 3 ms 764 KB Output is correct
30 Correct 4 ms 764 KB Output is correct
31 Correct 3 ms 764 KB Output is correct
32 Correct 4 ms 764 KB Output is correct
33 Correct 4 ms 764 KB Output is correct
34 Correct 3 ms 764 KB Output is correct
35 Correct 4 ms 764 KB Output is correct
36 Correct 4 ms 764 KB Output is correct
37 Correct 3 ms 764 KB Output is correct
38 Correct 3 ms 764 KB Output is correct
39 Correct 4 ms 768 KB Output is correct
40 Correct 4 ms 768 KB Output is correct
41 Correct 4 ms 768 KB Output is correct
42 Correct 4 ms 768 KB Output is correct
43 Correct 4 ms 768 KB Output is correct
44 Correct 3 ms 768 KB Output is correct
45 Correct 4 ms 768 KB Output is correct
46 Correct 4 ms 768 KB Output is correct
47 Correct 3 ms 768 KB Output is correct
48 Correct 3 ms 768 KB Output is correct
49 Correct 3 ms 768 KB Output is correct
50 Correct 4 ms 768 KB Output is correct
51 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 456 KB Output is correct
4 Correct 2 ms 472 KB Output is correct
5 Correct 2 ms 660 KB Output is correct
6 Correct 2 ms 660 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 2 ms 696 KB Output is correct
13 Correct 2 ms 696 KB Output is correct
14 Correct 2 ms 696 KB Output is correct
15 Correct 2 ms 696 KB Output is correct
16 Correct 2 ms 696 KB Output is correct
17 Correct 2 ms 696 KB Output is correct
18 Correct 2 ms 696 KB Output is correct
19 Correct 2 ms 696 KB Output is correct
20 Correct 2 ms 696 KB Output is correct
21 Correct 2 ms 696 KB Output is correct
22 Correct 2 ms 696 KB Output is correct
23 Correct 2 ms 696 KB Output is correct
24 Correct 2 ms 696 KB Output is correct
25 Correct 2 ms 696 KB Output is correct
26 Correct 2 ms 696 KB Output is correct
27 Correct 3 ms 764 KB Output is correct
28 Correct 4 ms 764 KB Output is correct
29 Correct 3 ms 764 KB Output is correct
30 Correct 4 ms 764 KB Output is correct
31 Correct 3 ms 764 KB Output is correct
32 Correct 4 ms 764 KB Output is correct
33 Correct 4 ms 764 KB Output is correct
34 Correct 3 ms 764 KB Output is correct
35 Correct 4 ms 764 KB Output is correct
36 Correct 4 ms 764 KB Output is correct
37 Correct 3 ms 764 KB Output is correct
38 Correct 3 ms 764 KB Output is correct
39 Correct 4 ms 768 KB Output is correct
40 Correct 4 ms 768 KB Output is correct
41 Correct 4 ms 768 KB Output is correct
42 Correct 4 ms 768 KB Output is correct
43 Correct 4 ms 768 KB Output is correct
44 Correct 3 ms 768 KB Output is correct
45 Correct 4 ms 768 KB Output is correct
46 Correct 4 ms 768 KB Output is correct
47 Correct 3 ms 768 KB Output is correct
48 Correct 3 ms 768 KB Output is correct
49 Correct 3 ms 768 KB Output is correct
50 Correct 4 ms 768 KB Output is correct
51 Correct 3 ms 768 KB Output is correct
52 Correct 201 ms 21040 KB Output is correct
53 Correct 215 ms 33800 KB Output is correct
54 Correct 197 ms 46412 KB Output is correct
55 Correct 196 ms 59184 KB Output is correct
56 Correct 212 ms 71716 KB Output is correct
57 Correct 203 ms 84464 KB Output is correct
58 Correct 197 ms 97200 KB Output is correct
59 Correct 208 ms 109752 KB Output is correct
60 Correct 192 ms 122492 KB Output is correct
61 Correct 193 ms 134988 KB Output is correct
62 Correct 198 ms 147708 KB Output is correct
63 Correct 206 ms 160304 KB Output is correct
64 Correct 197 ms 173112 KB Output is correct
65 Correct 199 ms 184532 KB Output is correct
66 Correct 207 ms 197140 KB Output is correct
67 Correct 205 ms 208348 KB Output is correct
68 Correct 195 ms 221016 KB Output is correct