답안 #856804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856804 2023-10-04T15:44:57 Z quanlt206 Art Exhibition (JOI18_art) C++17
100 / 100
136 ms 27960 KB
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 1e6 + 7;

pll a[N];

ll pre[N];

int n;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    FOR(i, 1, n) cin>>a[i].X>>a[i].Y;
    sort(a + 1, a + 1 + n);
    FOR(i, 1, n) pre[i] = pre[i - 1] + a[i].Y;
    ll Max = -9e18, res = -9e18;
    FOR(i, 1, n) {
        maximize(Max, -pre[i - 1] + a[i].X);
        maximize(res, pre[i] - a[i].X + Max);
    }
    cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2512 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2512 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2420 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2512 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2420 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 3 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2396 KB Output is correct
36 Correct 2 ms 2396 KB Output is correct
37 Correct 2 ms 2396 KB Output is correct
38 Correct 2 ms 2396 KB Output is correct
39 Correct 2 ms 2396 KB Output is correct
40 Correct 2 ms 2396 KB Output is correct
41 Correct 2 ms 2396 KB Output is correct
42 Correct 2 ms 2396 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 2 ms 2392 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 2 ms 2396 KB Output is correct
49 Correct 2 ms 2392 KB Output is correct
50 Correct 2 ms 2392 KB Output is correct
51 Correct 2 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2512 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2420 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 3 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 2 ms 2396 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 2 ms 2396 KB Output is correct
35 Correct 2 ms 2396 KB Output is correct
36 Correct 2 ms 2396 KB Output is correct
37 Correct 2 ms 2396 KB Output is correct
38 Correct 2 ms 2396 KB Output is correct
39 Correct 2 ms 2396 KB Output is correct
40 Correct 2 ms 2396 KB Output is correct
41 Correct 2 ms 2396 KB Output is correct
42 Correct 2 ms 2396 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 2 ms 2396 KB Output is correct
45 Correct 2 ms 2392 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 2 ms 2396 KB Output is correct
49 Correct 2 ms 2392 KB Output is correct
50 Correct 2 ms 2392 KB Output is correct
51 Correct 2 ms 2396 KB Output is correct
52 Correct 122 ms 14808 KB Output is correct
53 Correct 130 ms 27444 KB Output is correct
54 Correct 127 ms 27476 KB Output is correct
55 Correct 127 ms 27472 KB Output is correct
56 Correct 126 ms 27472 KB Output is correct
57 Correct 127 ms 27456 KB Output is correct
58 Correct 130 ms 27580 KB Output is correct
59 Correct 127 ms 27472 KB Output is correct
60 Correct 125 ms 27568 KB Output is correct
61 Correct 131 ms 27444 KB Output is correct
62 Correct 128 ms 27476 KB Output is correct
63 Correct 130 ms 27960 KB Output is correct
64 Correct 127 ms 27584 KB Output is correct
65 Correct 126 ms 27572 KB Output is correct
66 Correct 136 ms 27576 KB Output is correct
67 Correct 127 ms 27444 KB Output is correct
68 Correct 133 ms 27476 KB Output is correct