답안 #915468

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915468 2024-01-24T02:51:33 Z viwlesxq Art Exhibition (JOI18_art) C++17
100 / 100
159 ms 29116 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
    return a > b && (a = b) == b;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
    return a < b && (a = b) == b;
}
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
const int mod = 1e9 + 7;

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n; cin >> n;
    int a[n], b[n];
    vector<pair<int, int>> v;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
        v.push_back({a[i], b[i]});
    }
    sort(all(v));
    for (int i = 0; i < n; ++i) a[i] = v[i].first, b[i] = v[i].second;
    int res = b[0], pref = b[0], min = -a[0];
    for (int i = 1; i < n; ++i) {
        chmin(min, pref - a[i]);
        pref += b[i];
        chmax(res, pref - min - a[i]);
    }
    cout << res;
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 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 0 ms 460 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 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 0 ms 460 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 596 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 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 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 0 ms 460 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 596 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 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 860 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 672 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 3 ms 860 KB Output is correct
37 Correct 2 ms 728 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 2 ms 860 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 860 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 860 KB Output is correct
50 Correct 2 ms 860 KB Output is correct
51 Correct 2 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 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 0 ms 460 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 596 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 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 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 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 860 KB Output is correct
31 Correct 2 ms 724 KB Output is correct
32 Correct 2 ms 672 KB Output is correct
33 Correct 2 ms 860 KB Output is correct
34 Correct 2 ms 860 KB Output is correct
35 Correct 2 ms 860 KB Output is correct
36 Correct 3 ms 860 KB Output is correct
37 Correct 2 ms 728 KB Output is correct
38 Correct 2 ms 860 KB Output is correct
39 Correct 2 ms 860 KB Output is correct
40 Correct 2 ms 860 KB Output is correct
41 Correct 2 ms 860 KB Output is correct
42 Correct 2 ms 860 KB Output is correct
43 Correct 2 ms 860 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 2 ms 860 KB Output is correct
46 Correct 2 ms 860 KB Output is correct
47 Correct 2 ms 860 KB Output is correct
48 Correct 2 ms 860 KB Output is correct
49 Correct 2 ms 860 KB Output is correct
50 Correct 2 ms 860 KB Output is correct
51 Correct 2 ms 980 KB Output is correct
52 Correct 159 ms 28600 KB Output is correct
53 Correct 151 ms 28736 KB Output is correct
54 Correct 142 ms 28644 KB Output is correct
55 Correct 143 ms 28760 KB Output is correct
56 Correct 140 ms 28860 KB Output is correct
57 Correct 136 ms 28684 KB Output is correct
58 Correct 149 ms 28776 KB Output is correct
59 Correct 154 ms 28912 KB Output is correct
60 Correct 137 ms 28844 KB Output is correct
61 Correct 147 ms 28592 KB Output is correct
62 Correct 138 ms 28864 KB Output is correct
63 Correct 137 ms 28768 KB Output is correct
64 Correct 149 ms 28852 KB Output is correct
65 Correct 142 ms 28764 KB Output is correct
66 Correct 135 ms 29116 KB Output is correct
67 Correct 143 ms 28852 KB Output is correct
68 Correct 136 ms 28700 KB Output is correct