답안 #1112571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112571 2024-11-14T10:55:54 Z Tymond Art Exhibition (JOI18_art) C++17
100 / 100
139 ms 24904 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define fi first
#define se second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const ll INF = 1e17;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin >> n;
    vector<pll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].fi >> a[i].se;
    }

    sort(all(a));
    vll pref(n, 0LL);
    pref[0] = a[0].se;
    for(int i = 1; i < n; i++){
        pref[i] = (ll)pref[i - 1] + a[i].se;
    }

    ll ans = -INF;
    ll mx = -INF;
    for(int i = 0; i < n; i++){
        ll x = pref[i] - (a[i].fi - a[0].fi);
        ans = max(ans, x);
        x += mx;
        ans = max(ans, x);
        if(i + 1 < n){
            mx = max(mx, (a[i + 1].fi - a[0].fi) - pref[i]);
        }
    }

    cout << ans << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 504 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 500 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 504 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 500 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 3 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 592 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 3 ms 476 KB Output is correct
34 Correct 2 ms 592 KB Output is correct
35 Correct 2 ms 760 KB Output is correct
36 Correct 2 ms 592 KB Output is correct
37 Correct 2 ms 592 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 2 ms 592 KB Output is correct
40 Correct 3 ms 592 KB Output is correct
41 Correct 2 ms 592 KB Output is correct
42 Correct 2 ms 660 KB Output is correct
43 Correct 3 ms 592 KB Output is correct
44 Correct 3 ms 592 KB Output is correct
45 Correct 2 ms 592 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 3 ms 660 KB Output is correct
48 Correct 2 ms 476 KB Output is correct
49 Correct 2 ms 592 KB Output is correct
50 Correct 2 ms 592 KB Output is correct
51 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 504 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 500 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 3 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
29 Correct 2 ms 592 KB Output is correct
30 Correct 2 ms 592 KB Output is correct
31 Correct 2 ms 592 KB Output is correct
32 Correct 2 ms 592 KB Output is correct
33 Correct 3 ms 476 KB Output is correct
34 Correct 2 ms 592 KB Output is correct
35 Correct 2 ms 760 KB Output is correct
36 Correct 2 ms 592 KB Output is correct
37 Correct 2 ms 592 KB Output is correct
38 Correct 2 ms 592 KB Output is correct
39 Correct 2 ms 592 KB Output is correct
40 Correct 3 ms 592 KB Output is correct
41 Correct 2 ms 592 KB Output is correct
42 Correct 2 ms 660 KB Output is correct
43 Correct 3 ms 592 KB Output is correct
44 Correct 3 ms 592 KB Output is correct
45 Correct 2 ms 592 KB Output is correct
46 Correct 2 ms 592 KB Output is correct
47 Correct 3 ms 660 KB Output is correct
48 Correct 2 ms 476 KB Output is correct
49 Correct 2 ms 592 KB Output is correct
50 Correct 2 ms 592 KB Output is correct
51 Correct 2 ms 632 KB Output is correct
52 Correct 124 ms 24668 KB Output is correct
53 Correct 134 ms 24648 KB Output is correct
54 Correct 139 ms 24648 KB Output is correct
55 Correct 126 ms 24656 KB Output is correct
56 Correct 124 ms 24648 KB Output is correct
57 Correct 139 ms 24656 KB Output is correct
58 Correct 135 ms 24668 KB Output is correct
59 Correct 130 ms 24656 KB Output is correct
60 Correct 129 ms 24796 KB Output is correct
61 Correct 126 ms 24648 KB Output is correct
62 Correct 128 ms 24648 KB Output is correct
63 Correct 125 ms 24648 KB Output is correct
64 Correct 133 ms 24904 KB Output is correct
65 Correct 120 ms 24648 KB Output is correct
66 Correct 120 ms 24648 KB Output is correct
67 Correct 135 ms 24648 KB Output is correct
68 Correct 123 ms 24648 KB Output is correct