답안 #918315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918315 2024-01-29T15:52:58 Z vjudge1 Art Exhibition (JOI18_art) C++17
100 / 100
182 ms 15956 KB
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
//-----------------------
// #define   ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define            ll long long
#define           ull unsigned long long
#define            pb push_back
#define            pf push_front
#define            mp make_pair
#define      mem(f,x) memset(f, x, sizeof(f))
#define   __lcm(a, b) (1ll * a * b) / __gcd(a, b)
#define  bit(mask, i) ((mask >> i) & 1)
#define           pii pair<int, int>
#define           pll pair<ll, ll>
#define            el '\n'
#define             F first
#define             S second
#define         io(x) freopen(x".inp","r",stdin),freopen(x".out","w",stdout)
//-----------------------
const ll INF = 1e18;
const int MOD = 1e9 + 7;
const int MULTI = 0;
const int dx[4] = {0, 0, 1, -1}; //R L D U
const int dy[4] = {1, -1, 0, 0};
//-----AUTHOR trvhung VNG High School for Gifted Student-----

const int maxn = 6e5 + 5;
int n;
pll a[maxn];

void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i].F >> a[i].S;

	sort(a + 1, a + 1 + n);
	ll low, ans, pref; low = ans = pref = 0;
	for (int i = 1; i <= n; ++i) {
		low = min(low, pref - a[i].F);
		pref += a[i].S;
		ans = max(ans, pref - a[i].F - low);
	}

	cout << ans << el;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    if (!MULTI) solve();
    else {
        int test; cin >> test;
        while (test--) solve();
    }
    
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 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 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 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 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 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 3 ms 484 KB Output is correct
31 Correct 2 ms 616 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 632 KB Output is correct
36 Correct 2 ms 584 KB Output is correct
37 Correct 2 ms 756 KB Output is correct
38 Correct 2 ms 600 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 660 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 800 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 644 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 2 ms 604 KB Output is correct
51 Correct 2 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 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 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 3 ms 484 KB Output is correct
31 Correct 2 ms 616 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 472 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 632 KB Output is correct
36 Correct 2 ms 584 KB Output is correct
37 Correct 2 ms 756 KB Output is correct
38 Correct 2 ms 600 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 2 ms 660 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 2 ms 800 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 644 KB Output is correct
49 Correct 2 ms 600 KB Output is correct
50 Correct 2 ms 604 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 129 ms 15956 KB Output is correct
53 Correct 182 ms 15540 KB Output is correct
54 Correct 146 ms 15728 KB Output is correct
55 Correct 129 ms 15736 KB Output is correct
56 Correct 132 ms 15740 KB Output is correct
57 Correct 148 ms 15692 KB Output is correct
58 Correct 137 ms 15596 KB Output is correct
59 Correct 143 ms 15700 KB Output is correct
60 Correct 130 ms 15656 KB Output is correct
61 Correct 156 ms 15484 KB Output is correct
62 Correct 126 ms 15744 KB Output is correct
63 Correct 164 ms 15712 KB Output is correct
64 Correct 136 ms 15668 KB Output is correct
65 Correct 130 ms 15504 KB Output is correct
66 Correct 128 ms 15568 KB Output is correct
67 Correct 148 ms 15728 KB Output is correct
68 Correct 146 ms 15860 KB Output is correct