답안 #678555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
678555 2023-01-06T07:27:28 Z tranxuanbach Art Exhibition (JOI18_art) C++17
100 / 100
223 ms 13992 KB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (auto i = (l); i < (r); i++)
#define ForE(i, l, r) for (auto i = (l); i <= (r); i++)
#define FordE(i, l, r) for (auto i = (l); i >= (r); i--)
#define Fora(v, a) for (auto v: (a))
#define bend(a) (a).begin(), (a).end()
#define isz(a) ((signed)(a).size())

using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pii>;
using vvi = vector <vi>;

const int N = 5e5 + 5;

int n;
pair <ll, int> a[N];
ll b[N];

ll c[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("KEK.inp", "r", stdin);
    // freopen("KEK.out", "w", stdout);
    cin >> n;
    ForE(i, 1, n){
        cin >> a[i].fi >> a[i].se;
    }
    sort(a + 1, a + n + 1);
    ForE(i, 1, n){
        b[i] = b[i - 1] + a[i].se;
    }

    ll ans = 0, val = numeric_limits <ll>::min();
    ForE(i, 1, n){
        val = max(val, a[i].fi - b[i - 1]);
        ans = max(ans, b[i] - a[i].fi + val);
    }
    cout << ans << endl;
}

/*
==================================================+
INPUT                                             |
--------------------------------------------------|

--------------------------------------------------|
==================================================+
OUTPUT                                            |
--------------------------------------------------|

--------------------------------------------------|
==================================================+
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 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 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 336 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 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 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 336 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 3 ms 472 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 472 KB Output is correct
35 Correct 2 ms 580 KB Output is correct
36 Correct 3 ms 528 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 2 ms 576 KB Output is correct
40 Correct 2 ms 472 KB Output is correct
41 Correct 3 ms 596 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 580 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 3 ms 584 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 2 ms 472 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 2 ms 488 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 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 332 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 336 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 3 ms 472 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 3 ms 472 KB Output is correct
35 Correct 2 ms 580 KB Output is correct
36 Correct 3 ms 528 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 2 ms 576 KB Output is correct
40 Correct 2 ms 472 KB Output is correct
41 Correct 3 ms 596 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 580 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 3 ms 584 KB Output is correct
46 Correct 2 ms 596 KB Output is correct
47 Correct 2 ms 472 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 2 ms 488 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 186 ms 13784 KB Output is correct
53 Correct 166 ms 13848 KB Output is correct
54 Correct 164 ms 13916 KB Output is correct
55 Correct 156 ms 13788 KB Output is correct
56 Correct 184 ms 13848 KB Output is correct
57 Correct 187 ms 13876 KB Output is correct
58 Correct 166 ms 13780 KB Output is correct
59 Correct 172 ms 13852 KB Output is correct
60 Correct 176 ms 13832 KB Output is correct
61 Correct 157 ms 13792 KB Output is correct
62 Correct 223 ms 13864 KB Output is correct
63 Correct 165 ms 13772 KB Output is correct
64 Correct 163 ms 13992 KB Output is correct
65 Correct 160 ms 13756 KB Output is correct
66 Correct 167 ms 13784 KB Output is correct
67 Correct 158 ms 13788 KB Output is correct
68 Correct 156 ms 13788 KB Output is correct