Submission #350000

# Submission time Handle Problem Language Result Execution time Memory
350000 2021-01-18T20:17:19 Z Pulgster Art Exhibition (JOI18_art) C++17
100 / 100
543 ms 24928 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
    sim > struct rge { c b, e; };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c* x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug {
#ifdef LOCAL
        ~debug() { cerr << endl; }
        eni(!=) cerr << boolalpha << i; ris; }
        eni(==) ris << range(begin(i), end(i)); }
        sim, class b dor(pair < b, c > d) {
            ris << "(" << d.first << ", " << d.second << ")";
        }
        sim dor(rge<c> d) {
            *this << "[";
            for (auto it = d.b; it != d.e; ++it)
                *this << ", " + 2 * (it == d.b) << *it;
            ris << "]";
        }
#else
        sim dor(const c&) { ris; }
#endif
    };
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define pb push_back
#define pii pair<int, int> 
#define pll pair<ll, ll>
#define vi vector<int>
#define vec vector
#define eb emplace_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
    void read(vector<ll> &a){
        for(ll &i : a) cin >> i;
    }
void read(vector<int> &a){
    for(int &i : a) cin >> i;
}ll INF = 1e18;
int mod = 1e9+7;

long long fastpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
vector<int> pow2(25);
const int maxn = 1e6+6;
const int maxk = 10;

void test_case(int tnum){
   int n;
    cin >> n;
    vector<pair<ll, ll>> a;
    for(int i = 0; i < n; i++){
        ll sz, p;
        cin >> sz >> p;
        a.pb({sz, p});
    }
    sort(a.begin(), a.end());
    vector<ll> pref(n+1);
    pref[0] = 0;
    for(int i = 1; i <= n; i++){
        pref[i] = pref[i-1] + a[i-1].second;
    }
    ll best = -INF;
    ll ans = -INF;
    for(int i = 0; i < n; i++){
        best = max(best, a[i].first - pref[i]);
        ans = max(ans, pref[i+1] + best - a[i].first);
        // debug() << imie(best);
    }
    cout << ans << '\n';
}

int main(void){
    cin.tie(0);
    int t = 1;
    // cin >>t;
    for(int test = 1; test <= t; test++){
        // cout << "Case #" << test << ": ";
        test_case(test);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 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 364 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 1 ms 364 KB Output is correct
24 Correct 1 ms 384 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 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 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 364 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 1 ms 364 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 492 KB Output is correct
29 Correct 6 ms 492 KB Output is correct
30 Correct 6 ms 492 KB Output is correct
31 Correct 6 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 5 ms 492 KB Output is correct
34 Correct 6 ms 492 KB Output is correct
35 Correct 6 ms 492 KB Output is correct
36 Correct 6 ms 492 KB Output is correct
37 Correct 6 ms 492 KB Output is correct
38 Correct 6 ms 492 KB Output is correct
39 Correct 6 ms 492 KB Output is correct
40 Correct 6 ms 492 KB Output is correct
41 Correct 5 ms 492 KB Output is correct
42 Correct 6 ms 492 KB Output is correct
43 Correct 6 ms 492 KB Output is correct
44 Correct 6 ms 492 KB Output is correct
45 Correct 6 ms 492 KB Output is correct
46 Correct 6 ms 492 KB Output is correct
47 Correct 6 ms 492 KB Output is correct
48 Correct 6 ms 492 KB Output is correct
49 Correct 6 ms 492 KB Output is correct
50 Correct 6 ms 492 KB Output is correct
51 Correct 6 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 0 ms 364 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 364 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 1 ms 364 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 492 KB Output is correct
29 Correct 6 ms 492 KB Output is correct
30 Correct 6 ms 492 KB Output is correct
31 Correct 6 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 5 ms 492 KB Output is correct
34 Correct 6 ms 492 KB Output is correct
35 Correct 6 ms 492 KB Output is correct
36 Correct 6 ms 492 KB Output is correct
37 Correct 6 ms 492 KB Output is correct
38 Correct 6 ms 492 KB Output is correct
39 Correct 6 ms 492 KB Output is correct
40 Correct 6 ms 492 KB Output is correct
41 Correct 5 ms 492 KB Output is correct
42 Correct 6 ms 492 KB Output is correct
43 Correct 6 ms 492 KB Output is correct
44 Correct 6 ms 492 KB Output is correct
45 Correct 6 ms 492 KB Output is correct
46 Correct 6 ms 492 KB Output is correct
47 Correct 6 ms 492 KB Output is correct
48 Correct 6 ms 492 KB Output is correct
49 Correct 6 ms 492 KB Output is correct
50 Correct 6 ms 492 KB Output is correct
51 Correct 6 ms 492 KB Output is correct
52 Correct 531 ms 12104 KB Output is correct
53 Correct 538 ms 24776 KB Output is correct
54 Correct 534 ms 24648 KB Output is correct
55 Correct 532 ms 24712 KB Output is correct
56 Correct 535 ms 24928 KB Output is correct
57 Correct 536 ms 24776 KB Output is correct
58 Correct 539 ms 24828 KB Output is correct
59 Correct 535 ms 24908 KB Output is correct
60 Correct 532 ms 24776 KB Output is correct
61 Correct 534 ms 24656 KB Output is correct
62 Correct 540 ms 24788 KB Output is correct
63 Correct 536 ms 24648 KB Output is correct
64 Correct 538 ms 24780 KB Output is correct
65 Correct 537 ms 24752 KB Output is correct
66 Correct 543 ms 24776 KB Output is correct
67 Correct 534 ms 24804 KB Output is correct
68 Correct 536 ms 24776 KB Output is correct