Submission #880240

# Submission time Handle Problem Language Result Execution time Memory
880240 2023-11-29T04:08:38 Z niter Art Exhibition (JOI18_art) C++14
50 / 100
25 ms 6424 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define entr cerr << endl;
#define spac cerr << ' ';
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x <<  " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) x.begin(), x.end()
#define unilize(x) x.resize(unique(BAE(x)) - x.begin())
#define unisort(x) sort(BAE(x)); unilize(x);
using namespace std;
typedef long long ll;

struct P{
    ll A, B;
    bool operator<(P x){
        return (A == x.A) ? (B < x.B) : (A < x.A);
    }
};
const int mxn = (int)(1e5) + 10;
P x[mxn];
//P y[mxn];

int solve(int n){
//    int real_ans;
//    string ans_mask;
//    cin >> real_ans >> ans_mask;
    ll ans = -(1e18);
    loop(i,1,n+1){
        cin >> x[i].A >> x[i].B;
//        y[i] = x[i];
    }
    x[0].A = x[0].B = 0;
    sort(x + 1, x + n + 1);
    ll mx = x[1].A, add = 0;
    for(int i = 1; i <= n; i++){
        if(i != 1){
            mx = max(mx, x[i].A - add);
        }
        add += x[i].B;
//        opa(i) opa(mx) opa(add) op(x[i].A)
        ans = max(ans, -x[i].A + mx + add);
    }
//    if(ans != real_ans){
//        opa(ans) op(real_ans)
//        op(ans_mask)
//        loop(i,1,n+1){
//            ops(y[i].A) spac ops(y[i].B) entr
//        } entr
//        exit(0);
//    }
    cout << ans;
    return 0;
}

int main(){
//    freopen("res.txt", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    solve(n);
}
/*
4 81 0110
2 10
42 42
48 45
7 12

3 50 010
2 5
24 50
1 13
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 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 0 ms 348 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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 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 0 ms 348 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 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 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 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 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 0 ms 348 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 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 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 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 580 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 2 ms 648 KB Output is correct
36 Correct 2 ms 836 KB Output is correct
37 Correct 2 ms 524 KB Output is correct
38 Correct 2 ms 584 KB Output is correct
39 Correct 2 ms 600 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 1 ms 476 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 2 ms 616 KB Output is correct
48 Correct 2 ms 616 KB Output is correct
49 Correct 2 ms 524 KB Output is correct
50 Correct 2 ms 616 KB Output is correct
51 Correct 3 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 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 0 ms 348 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 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 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 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 580 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 2 ms 648 KB Output is correct
36 Correct 2 ms 836 KB Output is correct
37 Correct 2 ms 524 KB Output is correct
38 Correct 2 ms 584 KB Output is correct
39 Correct 2 ms 600 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 1 ms 476 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 2 ms 616 KB Output is correct
48 Correct 2 ms 616 KB Output is correct
49 Correct 2 ms 524 KB Output is correct
50 Correct 2 ms 616 KB Output is correct
51 Correct 3 ms 876 KB Output is correct
52 Runtime error 25 ms 6424 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -