답안 #912432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912432 2024-01-19T12:59:06 Z NK_ Art Exhibition (JOI18_art) C++17
100 / 100
186 ms 28908 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define pb push_back

using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using vl = V<ll>;

const ll INFL = 2e18;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; cin >> N;

	vl A(N), B(N); for(int i = 0; i < N; i++) cin >> A[i] >> B[i];

	vi ord(N); iota(begin(ord), end(ord), 0);
	sort(begin(ord), end(ord), [&](int x, int y) {
		return A[x] < A[y];
	});

	vl P = {0}; for(auto& i : ord) P.pb(P.back() + B[i]);

	ll ans = 0, mn = INFL;

	for(int i = 0; i <= N; i++) {
		if (i != 0) {
			ans = max(P[i] - A[ord[i - 1]] - mn, ans);
		}

		if (i != N) mn = min(P[i] - A[ord[i]], mn);
	}

	cout << ans << nl;
	exit(0-0);
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 664 KB Output is correct
37 Correct 2 ms 660 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 644 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 664 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 2 ms 648 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 2 ms 600 KB Output is correct
51 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 456 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 664 KB Output is correct
37 Correct 2 ms 660 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 644 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 664 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 2 ms 648 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 2 ms 600 KB Output is correct
51 Correct 3 ms 604 KB Output is correct
52 Correct 186 ms 28236 KB Output is correct
53 Correct 149 ms 28908 KB Output is correct
54 Correct 148 ms 28616 KB Output is correct
55 Correct 156 ms 27200 KB Output is correct
56 Correct 145 ms 27864 KB Output is correct
57 Correct 152 ms 28372 KB Output is correct
58 Correct 154 ms 27092 KB Output is correct
59 Correct 181 ms 28868 KB Output is correct
60 Correct 159 ms 27852 KB Output is correct
61 Correct 152 ms 28860 KB Output is correct
62 Correct 148 ms 27712 KB Output is correct
63 Correct 147 ms 28176 KB Output is correct
64 Correct 154 ms 28516 KB Output is correct
65 Correct 145 ms 27336 KB Output is correct
66 Correct 151 ms 28748 KB Output is correct
67 Correct 155 ms 28616 KB Output is correct
68 Correct 147 ms 27708 KB Output is correct