Submission #378248

# Submission time Handle Problem Language Result Execution time Memory
378248 2021-03-16T10:26:45 Z jlallas384 Art Exhibition (JOI18_art) C++17
100 / 100
825 ms 48468 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<pair<ll,int>> a(n);
    for(auto &[sz,val]: a){
        cin >> sz >> val;
    }
    sort(a.begin(), a.end());
    vector<ll> b(n);
    multiset<ll> ms;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i].second;
        ll x = sum - (a[i].first - a[0].first);
        b[i] = x;
        ms.insert(x);
    }
    ll ans = *ms.rbegin(), pref = 0;
    for(int i = 1; i < n; i++){
        ms.erase(ms.find(b[i-1]));
        pref -= a[i-1].second;
        ans = max(ans, *ms.rbegin() + pref + (a[i].first - a[0].first));
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 7 ms 748 KB Output is correct
28 Correct 7 ms 748 KB Output is correct
29 Correct 7 ms 748 KB Output is correct
30 Correct 7 ms 768 KB Output is correct
31 Correct 7 ms 748 KB Output is correct
32 Correct 7 ms 748 KB Output is correct
33 Correct 9 ms 748 KB Output is correct
34 Correct 9 ms 748 KB Output is correct
35 Correct 9 ms 748 KB Output is correct
36 Correct 9 ms 748 KB Output is correct
37 Correct 7 ms 748 KB Output is correct
38 Correct 8 ms 748 KB Output is correct
39 Correct 8 ms 748 KB Output is correct
40 Correct 8 ms 748 KB Output is correct
41 Correct 7 ms 748 KB Output is correct
42 Correct 8 ms 748 KB Output is correct
43 Correct 7 ms 748 KB Output is correct
44 Correct 8 ms 748 KB Output is correct
45 Correct 7 ms 748 KB Output is correct
46 Correct 7 ms 748 KB Output is correct
47 Correct 7 ms 748 KB Output is correct
48 Correct 7 ms 748 KB Output is correct
49 Correct 7 ms 876 KB Output is correct
50 Correct 9 ms 748 KB Output is correct
51 Correct 7 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 7 ms 748 KB Output is correct
28 Correct 7 ms 748 KB Output is correct
29 Correct 7 ms 748 KB Output is correct
30 Correct 7 ms 768 KB Output is correct
31 Correct 7 ms 748 KB Output is correct
32 Correct 7 ms 748 KB Output is correct
33 Correct 9 ms 748 KB Output is correct
34 Correct 9 ms 748 KB Output is correct
35 Correct 9 ms 748 KB Output is correct
36 Correct 9 ms 748 KB Output is correct
37 Correct 7 ms 748 KB Output is correct
38 Correct 8 ms 748 KB Output is correct
39 Correct 8 ms 748 KB Output is correct
40 Correct 8 ms 748 KB Output is correct
41 Correct 7 ms 748 KB Output is correct
42 Correct 8 ms 748 KB Output is correct
43 Correct 7 ms 748 KB Output is correct
44 Correct 8 ms 748 KB Output is correct
45 Correct 7 ms 748 KB Output is correct
46 Correct 7 ms 748 KB Output is correct
47 Correct 7 ms 748 KB Output is correct
48 Correct 7 ms 748 KB Output is correct
49 Correct 7 ms 876 KB Output is correct
50 Correct 9 ms 748 KB Output is correct
51 Correct 7 ms 748 KB Output is correct
52 Correct 695 ms 48120 KB Output is correct
53 Correct 689 ms 48364 KB Output is correct
54 Correct 720 ms 48364 KB Output is correct
55 Correct 751 ms 48248 KB Output is correct
56 Correct 825 ms 48244 KB Output is correct
57 Correct 818 ms 48248 KB Output is correct
58 Correct 764 ms 48216 KB Output is correct
59 Correct 753 ms 48376 KB Output is correct
60 Correct 758 ms 48468 KB Output is correct
61 Correct 766 ms 48144 KB Output is correct
62 Correct 723 ms 48364 KB Output is correct
63 Correct 712 ms 48364 KB Output is correct
64 Correct 707 ms 48236 KB Output is correct
65 Correct 693 ms 48364 KB Output is correct
66 Correct 680 ms 48364 KB Output is correct
67 Correct 703 ms 48364 KB Output is correct
68 Correct 736 ms 48364 KB Output is correct