답안 #591404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
591404 2022-07-07T11:52:23 Z shrimb Art Exhibition (JOI18_art) C++17
100 / 100
437 ms 44336 KB
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")

#include"bits/stdc++.h"
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;

#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991

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

    int n;
    cin >> n;
    pair<int,int> a[n];
    for (auto &[x, y] : a) cin >> x >> y;
    sort(a, a + n);

    multiset<int> s = {0};

    int sm = 0;
    for (int i = n - 1 ; i > 0 ; i--) {
        sm += a[i].second + a[i - 1].first - a[i].first;
        s.insert(sm);
    }
    sm += a[0].second;
    int ans = 0;
    for (int i = 0 ; i < n ; i++) ans = max(ans, a[i].second);
    for (int i = 0 ; i < n - 1 ; i++) {
        ans = max(ans, sm - *s.begin());
        sm -= a[i].second;
        s.erase(s.find(sm));
        sm += a[i + 1].first;
        sm -= a[i].first;
    }
    cout << ans << endl;
}

Compilation message

art.cpp:17:1: warning: multi-line comment [-Wcomment]
   17 | //\
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 708 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 3 ms 724 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 724 KB Output is correct
34 Correct 4 ms 736 KB Output is correct
35 Correct 3 ms 712 KB Output is correct
36 Correct 3 ms 724 KB Output is correct
37 Correct 4 ms 724 KB Output is correct
38 Correct 3 ms 740 KB Output is correct
39 Correct 3 ms 724 KB Output is correct
40 Correct 3 ms 712 KB Output is correct
41 Correct 3 ms 724 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 3 ms 724 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 3 ms 724 KB Output is correct
47 Correct 4 ms 652 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 3 ms 720 KB Output is correct
50 Correct 3 ms 724 KB Output is correct
51 Correct 3 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 4 ms 632 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 708 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 3 ms 724 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 724 KB Output is correct
34 Correct 4 ms 736 KB Output is correct
35 Correct 3 ms 712 KB Output is correct
36 Correct 3 ms 724 KB Output is correct
37 Correct 4 ms 724 KB Output is correct
38 Correct 3 ms 740 KB Output is correct
39 Correct 3 ms 724 KB Output is correct
40 Correct 3 ms 712 KB Output is correct
41 Correct 3 ms 724 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 3 ms 724 KB Output is correct
44 Correct 3 ms 724 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 3 ms 724 KB Output is correct
47 Correct 4 ms 652 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 3 ms 720 KB Output is correct
50 Correct 3 ms 724 KB Output is correct
51 Correct 3 ms 724 KB Output is correct
52 Correct 294 ms 43636 KB Output is correct
53 Correct 277 ms 44184 KB Output is correct
54 Correct 317 ms 44156 KB Output is correct
55 Correct 309 ms 44248 KB Output is correct
56 Correct 340 ms 44336 KB Output is correct
57 Correct 364 ms 44236 KB Output is correct
58 Correct 326 ms 44156 KB Output is correct
59 Correct 313 ms 44200 KB Output is correct
60 Correct 342 ms 44256 KB Output is correct
61 Correct 305 ms 44120 KB Output is correct
62 Correct 437 ms 44216 KB Output is correct
63 Correct 325 ms 44236 KB Output is correct
64 Correct 309 ms 44252 KB Output is correct
65 Correct 310 ms 44252 KB Output is correct
66 Correct 322 ms 44248 KB Output is correct
67 Correct 305 ms 44220 KB Output is correct
68 Correct 352 ms 44252 KB Output is correct