Submission #880398

# Submission time Handle Problem Language Result Execution time Memory
880398 2023-11-29T10:34:15 Z _KuroNeko_ Art Exhibition (JOI18_art) C++17
100 / 100
146 ms 26188 KB
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vdb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef set<int> si;
typedef set<long long> sl;
typedef set<double> sdb;
typedef set<string> ss;
typedef set<char> sc;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ftb(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define ft(i, a, b) for (int i = a, _b = b; i < _b; ++i)
#define fgb(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define fg(i, a, b) for (int i = a, _b = b; i > _b; --i)
#define endl "\n"
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<pll> a(n + 1,{0,0});
    ftb(i, 1, n) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    vl prefix_sum(n + 1, 0);
    ftb(i, 1, n) {
        prefix_sum[i] = prefix_sum[i - 1] + a[i].second;
    }
    vl d(n + 1, 0);
    d[n] = prefix_sum[n] - a[n].first;
    fgb(i, n - 1, 0) {
        d[i] = max(d[i + 1], prefix_sum[i] - a[i].first);
    }
    ll ans = 0;
    ftb(i, 1, n) {
        ans = max(ans, d[i] - prefix_sum[i - 1] + a[i].first);
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 360 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 360 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 720 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 640 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 644 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 668 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 2 ms 600 KB Output is correct
39 Correct 2 ms 584 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 644 KB Output is correct
43 Correct 2 ms 648 KB Output is correct
44 Correct 2 ms 600 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 648 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 2 ms 664 KB Output is correct
49 Correct 2 ms 728 KB Output is correct
50 Correct 2 ms 856 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 360 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 720 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 640 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 644 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 2 ms 604 KB Output is correct
35 Correct 2 ms 600 KB Output is correct
36 Correct 2 ms 668 KB Output is correct
37 Correct 2 ms 604 KB Output is correct
38 Correct 2 ms 600 KB Output is correct
39 Correct 2 ms 584 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 604 KB Output is correct
42 Correct 1 ms 644 KB Output is correct
43 Correct 2 ms 648 KB Output is correct
44 Correct 2 ms 600 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 648 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 2 ms 664 KB Output is correct
49 Correct 2 ms 728 KB Output is correct
50 Correct 2 ms 856 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 132 ms 25940 KB Output is correct
53 Correct 139 ms 25964 KB Output is correct
54 Correct 134 ms 26188 KB Output is correct
55 Correct 133 ms 25936 KB Output is correct
56 Correct 146 ms 25972 KB Output is correct
57 Correct 143 ms 26028 KB Output is correct
58 Correct 133 ms 25940 KB Output is correct
59 Correct 131 ms 26012 KB Output is correct
60 Correct 141 ms 26060 KB Output is correct
61 Correct 132 ms 25600 KB Output is correct
62 Correct 132 ms 25944 KB Output is correct
63 Correct 142 ms 25944 KB Output is correct
64 Correct 131 ms 26076 KB Output is correct
65 Correct 140 ms 25868 KB Output is correct
66 Correct 136 ms 26088 KB Output is correct
67 Correct 136 ms 25884 KB Output is correct
68 Correct 140 ms 25936 KB Output is correct