Submission #55911

# Submission time Handle Problem Language Result Execution time Memory
55911 2018-07-09T07:20:45 Z YaDon4ick Art Exhibition (JOI18_art) C++14
100 / 100
552 ms 132808 KB
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	int n;
	scanf("%d", &n);
	vector < pair < ll, ll > > a(n);
	for (int i = 0; i < n; i++)
		scanf("%lld%lld", &a[i].first, &a[i].second);
	sort(all(a));
	ll ans = 0, cur = 0;
	set < ll > st;
	for (int i = 0; i < n; i++)
	{	
		st.insert(a[i].first - cur);
		cur += a[i].second;
		ans = max(ans, cur - a[i].first + (*st.rbegin()));	
	} 	
	cout << ans << endl;

	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
art.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &a[i].first, &a[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 3 ms 564 KB Output is correct
10 Correct 2 ms 564 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 3 ms 564 KB Output is correct
10 Correct 2 ms 564 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 3 ms 588 KB Output is correct
13 Correct 2 ms 588 KB Output is correct
14 Correct 2 ms 588 KB Output is correct
15 Correct 3 ms 588 KB Output is correct
16 Correct 2 ms 588 KB Output is correct
17 Correct 2 ms 588 KB Output is correct
18 Correct 2 ms 588 KB Output is correct
19 Correct 2 ms 588 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 3 ms 564 KB Output is correct
10 Correct 2 ms 564 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 3 ms 588 KB Output is correct
13 Correct 2 ms 588 KB Output is correct
14 Correct 2 ms 588 KB Output is correct
15 Correct 3 ms 588 KB Output is correct
16 Correct 2 ms 588 KB Output is correct
17 Correct 2 ms 588 KB Output is correct
18 Correct 2 ms 588 KB Output is correct
19 Correct 2 ms 588 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 6 ms 896 KB Output is correct
28 Correct 6 ms 896 KB Output is correct
29 Correct 6 ms 896 KB Output is correct
30 Correct 5 ms 896 KB Output is correct
31 Correct 7 ms 896 KB Output is correct
32 Correct 8 ms 896 KB Output is correct
33 Correct 6 ms 896 KB Output is correct
34 Correct 14 ms 896 KB Output is correct
35 Correct 7 ms 896 KB Output is correct
36 Correct 6 ms 896 KB Output is correct
37 Correct 7 ms 920 KB Output is correct
38 Correct 6 ms 920 KB Output is correct
39 Correct 7 ms 920 KB Output is correct
40 Correct 7 ms 920 KB Output is correct
41 Correct 5 ms 920 KB Output is correct
42 Correct 6 ms 920 KB Output is correct
43 Correct 5 ms 920 KB Output is correct
44 Correct 5 ms 920 KB Output is correct
45 Correct 8 ms 920 KB Output is correct
46 Correct 6 ms 920 KB Output is correct
47 Correct 5 ms 920 KB Output is correct
48 Correct 5 ms 920 KB Output is correct
49 Correct 5 ms 920 KB Output is correct
50 Correct 8 ms 920 KB Output is correct
51 Correct 6 ms 920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 3 ms 480 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 3 ms 564 KB Output is correct
10 Correct 2 ms 564 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 3 ms 588 KB Output is correct
13 Correct 2 ms 588 KB Output is correct
14 Correct 2 ms 588 KB Output is correct
15 Correct 3 ms 588 KB Output is correct
16 Correct 2 ms 588 KB Output is correct
17 Correct 2 ms 588 KB Output is correct
18 Correct 2 ms 588 KB Output is correct
19 Correct 2 ms 588 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 6 ms 896 KB Output is correct
28 Correct 6 ms 896 KB Output is correct
29 Correct 6 ms 896 KB Output is correct
30 Correct 5 ms 896 KB Output is correct
31 Correct 7 ms 896 KB Output is correct
32 Correct 8 ms 896 KB Output is correct
33 Correct 6 ms 896 KB Output is correct
34 Correct 14 ms 896 KB Output is correct
35 Correct 7 ms 896 KB Output is correct
36 Correct 6 ms 896 KB Output is correct
37 Correct 7 ms 920 KB Output is correct
38 Correct 6 ms 920 KB Output is correct
39 Correct 7 ms 920 KB Output is correct
40 Correct 7 ms 920 KB Output is correct
41 Correct 5 ms 920 KB Output is correct
42 Correct 6 ms 920 KB Output is correct
43 Correct 5 ms 920 KB Output is correct
44 Correct 5 ms 920 KB Output is correct
45 Correct 8 ms 920 KB Output is correct
46 Correct 6 ms 920 KB Output is correct
47 Correct 5 ms 920 KB Output is correct
48 Correct 5 ms 920 KB Output is correct
49 Correct 5 ms 920 KB Output is correct
50 Correct 8 ms 920 KB Output is correct
51 Correct 6 ms 920 KB Output is correct
52 Correct 425 ms 31868 KB Output is correct
53 Correct 427 ms 31996 KB Output is correct
54 Correct 428 ms 31996 KB Output is correct
55 Correct 428 ms 31996 KB Output is correct
56 Correct 484 ms 31996 KB Output is correct
57 Correct 456 ms 31996 KB Output is correct
58 Correct 415 ms 44600 KB Output is correct
59 Correct 443 ms 57204 KB Output is correct
60 Correct 455 ms 69844 KB Output is correct
61 Correct 441 ms 82360 KB Output is correct
62 Correct 552 ms 95128 KB Output is correct
63 Correct 511 ms 107644 KB Output is correct
64 Correct 453 ms 120288 KB Output is correct
65 Correct 395 ms 132808 KB Output is correct
66 Correct 370 ms 132808 KB Output is correct
67 Correct 419 ms 132808 KB Output is correct
68 Correct 437 ms 132808 KB Output is correct