답안 #573410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
573410 2022-06-06T14:39:08 Z talant117408 Art Exhibition (JOI18_art) C++17
100 / 100
192 ms 28616 KB
#include <bits/stdc++.h>

//~ #ifndef EVAL
//~ #include "grader.cpp"
//~ #endif
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
#define pb                  push_back
#define mp                  make_pair
#define all(v)              (v).begin(),(v).end()
#define sz(v)               int((v).size())
#define do_not_disturb      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl                '\n'
 
int mod = 1e9+7;
 
ll modulo(ll a) {
    return ((a % mod) + mod) % mod;
}
 
ll add(ll a, ll b) {
    return modulo(a + b);
}
 
ll mult(ll a, ll b) {
    return modulo(a * b);
}
 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b&1) {
            res = mult(res, a);
        }
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector <pll> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin()+1, a.end());
    vector <ll> pref(n+1), saizu(n+1);
    for (int i = 1; i <= n; i++) {
        saizu[i] = a[i].first;
        pref[i] = pref[i-1] + a[i].second;
    }
    ll ans = -9e18, mx = 0;
    for (int i = 1; i <= n; i++) {
        mx = max(mx, saizu[i]-pref[i-1]);
        ans = max(ans, pref[i]-saizu[i]+mx);
    }
    cout << ans;
}

int main() {
    do_not_disturb
    
    int t = 1;
    //~ cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 2 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 568 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 524 KB Output is correct
34 Correct 3 ms 528 KB Output is correct
35 Correct 3 ms 596 KB Output is correct
36 Correct 4 ms 596 KB Output is correct
37 Correct 3 ms 516 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 2 ms 568 KB Output is correct
41 Correct 2 ms 568 KB Output is correct
42 Correct 2 ms 588 KB Output is correct
43 Correct 3 ms 512 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 2 ms 516 KB Output is correct
46 Correct 2 ms 588 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 2 ms 596 KB Output is correct
49 Correct 2 ms 512 KB Output is correct
50 Correct 3 ms 596 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 2 ms 596 KB Output is correct
28 Correct 2 ms 596 KB Output is correct
29 Correct 2 ms 568 KB Output is correct
30 Correct 2 ms 596 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 2 ms 596 KB Output is correct
33 Correct 2 ms 524 KB Output is correct
34 Correct 3 ms 528 KB Output is correct
35 Correct 3 ms 596 KB Output is correct
36 Correct 4 ms 596 KB Output is correct
37 Correct 3 ms 516 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 2 ms 568 KB Output is correct
41 Correct 2 ms 568 KB Output is correct
42 Correct 2 ms 588 KB Output is correct
43 Correct 3 ms 512 KB Output is correct
44 Correct 2 ms 596 KB Output is correct
45 Correct 2 ms 516 KB Output is correct
46 Correct 2 ms 588 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 2 ms 596 KB Output is correct
49 Correct 2 ms 512 KB Output is correct
50 Correct 3 ms 596 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 176 ms 28484 KB Output is correct
53 Correct 184 ms 28604 KB Output is correct
54 Correct 173 ms 28612 KB Output is correct
55 Correct 181 ms 28604 KB Output is correct
56 Correct 188 ms 28604 KB Output is correct
57 Correct 178 ms 28492 KB Output is correct
58 Correct 185 ms 28604 KB Output is correct
59 Correct 183 ms 28600 KB Output is correct
60 Correct 182 ms 28492 KB Output is correct
61 Correct 177 ms 28480 KB Output is correct
62 Correct 192 ms 28600 KB Output is correct
63 Correct 182 ms 28492 KB Output is correct
64 Correct 178 ms 28616 KB Output is correct
65 Correct 186 ms 28616 KB Output is correct
66 Correct 178 ms 28504 KB Output is correct
67 Correct 187 ms 28608 KB Output is correct
68 Correct 188 ms 28604 KB Output is correct