답안 #48474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48474 2018-05-13T22:09:02 Z kyleliu Art Exhibition (JOI18_art) C++14
100 / 100
253 ms 222984 KB
#include <bits/stdc++.h> // PLEASE

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pp;
#define MAXN 500005
#define MAXM 1005
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;
int N;
ll sz[MAXN], vl[MAXN];
pp ar[MAXN];
ll p[MAXN];

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for(int i=1; i<=N; i++) cin >> ar[i].A >> ar[i].B;
	sort(ar+1, ar+N+1);
	for(int i=1; i<=N; i++) {
		sz[i] = ar[i].A; vl[i] = ar[i].B;
		p[i] = p[i-1] + vl[i];
	}
	ll mv = sz[1] - p[0];
	ll ret = vl[1];
	for(int r=1; r<=N; r++) {
		mv = max(mv, sz[r] - p[r-1]);
		ret = max(ret, p[r] + mv - sz[r]);
	}
	cout << ret << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 484 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 484 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 2 ms 676 KB Output is correct
17 Correct 2 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 2 ms 676 KB Output is correct
20 Correct 2 ms 676 KB Output is correct
21 Correct 2 ms 676 KB Output is correct
22 Correct 2 ms 676 KB Output is correct
23 Correct 2 ms 676 KB Output is correct
24 Correct 2 ms 676 KB Output is correct
25 Correct 2 ms 676 KB Output is correct
26 Correct 2 ms 676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 484 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 2 ms 676 KB Output is correct
17 Correct 2 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 2 ms 676 KB Output is correct
20 Correct 2 ms 676 KB Output is correct
21 Correct 2 ms 676 KB Output is correct
22 Correct 2 ms 676 KB Output is correct
23 Correct 2 ms 676 KB Output is correct
24 Correct 2 ms 676 KB Output is correct
25 Correct 2 ms 676 KB Output is correct
26 Correct 2 ms 676 KB Output is correct
27 Correct 4 ms 868 KB Output is correct
28 Correct 4 ms 868 KB Output is correct
29 Correct 4 ms 868 KB Output is correct
30 Correct 4 ms 868 KB Output is correct
31 Correct 4 ms 868 KB Output is correct
32 Correct 4 ms 868 KB Output is correct
33 Correct 4 ms 868 KB Output is correct
34 Correct 4 ms 868 KB Output is correct
35 Correct 4 ms 868 KB Output is correct
36 Correct 4 ms 868 KB Output is correct
37 Correct 4 ms 868 KB Output is correct
38 Correct 4 ms 868 KB Output is correct
39 Correct 4 ms 868 KB Output is correct
40 Correct 4 ms 868 KB Output is correct
41 Correct 4 ms 868 KB Output is correct
42 Correct 4 ms 868 KB Output is correct
43 Correct 4 ms 868 KB Output is correct
44 Correct 4 ms 868 KB Output is correct
45 Correct 4 ms 868 KB Output is correct
46 Correct 4 ms 868 KB Output is correct
47 Correct 4 ms 868 KB Output is correct
48 Correct 4 ms 868 KB Output is correct
49 Correct 4 ms 868 KB Output is correct
50 Correct 4 ms 868 KB Output is correct
51 Correct 4 ms 868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 484 KB Output is correct
9 Correct 2 ms 536 KB Output is correct
10 Correct 2 ms 536 KB Output is correct
11 Correct 2 ms 536 KB Output is correct
12 Correct 2 ms 536 KB Output is correct
13 Correct 2 ms 536 KB Output is correct
14 Correct 2 ms 608 KB Output is correct
15 Correct 2 ms 608 KB Output is correct
16 Correct 2 ms 676 KB Output is correct
17 Correct 2 ms 676 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 2 ms 676 KB Output is correct
20 Correct 2 ms 676 KB Output is correct
21 Correct 2 ms 676 KB Output is correct
22 Correct 2 ms 676 KB Output is correct
23 Correct 2 ms 676 KB Output is correct
24 Correct 2 ms 676 KB Output is correct
25 Correct 2 ms 676 KB Output is correct
26 Correct 2 ms 676 KB Output is correct
27 Correct 4 ms 868 KB Output is correct
28 Correct 4 ms 868 KB Output is correct
29 Correct 4 ms 868 KB Output is correct
30 Correct 4 ms 868 KB Output is correct
31 Correct 4 ms 868 KB Output is correct
32 Correct 4 ms 868 KB Output is correct
33 Correct 4 ms 868 KB Output is correct
34 Correct 4 ms 868 KB Output is correct
35 Correct 4 ms 868 KB Output is correct
36 Correct 4 ms 868 KB Output is correct
37 Correct 4 ms 868 KB Output is correct
38 Correct 4 ms 868 KB Output is correct
39 Correct 4 ms 868 KB Output is correct
40 Correct 4 ms 868 KB Output is correct
41 Correct 4 ms 868 KB Output is correct
42 Correct 4 ms 868 KB Output is correct
43 Correct 4 ms 868 KB Output is correct
44 Correct 4 ms 868 KB Output is correct
45 Correct 4 ms 868 KB Output is correct
46 Correct 4 ms 868 KB Output is correct
47 Correct 4 ms 868 KB Output is correct
48 Correct 4 ms 868 KB Output is correct
49 Correct 4 ms 868 KB Output is correct
50 Correct 4 ms 868 KB Output is correct
51 Correct 4 ms 868 KB Output is correct
52 Correct 229 ms 20136 KB Output is correct
53 Correct 232 ms 32892 KB Output is correct
54 Correct 233 ms 45632 KB Output is correct
55 Correct 233 ms 58308 KB Output is correct
56 Correct 238 ms 71016 KB Output is correct
57 Correct 232 ms 83644 KB Output is correct
58 Correct 236 ms 96272 KB Output is correct
59 Correct 231 ms 108932 KB Output is correct
60 Correct 233 ms 121708 KB Output is correct
61 Correct 230 ms 134176 KB Output is correct
62 Correct 240 ms 146856 KB Output is correct
63 Correct 231 ms 159516 KB Output is correct
64 Correct 236 ms 172276 KB Output is correct
65 Correct 235 ms 184824 KB Output is correct
66 Correct 248 ms 197640 KB Output is correct
67 Correct 248 ms 210176 KB Output is correct
68 Correct 253 ms 222984 KB Output is correct