# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
847599 | 2023-09-10T03:45:01 Z | Amaarsaa | Art Exhibition (JOI18_art) | C++14 | 293 ms | 68256 KB |
#include<bits/stdc++.h> using namespace std; using ll = long long ; ll mid; struct Node{ ll Max = 0, Has = 0; Node *l, *r; }; void Change(Node *P, ll lo, ll hi, ll st, ll fn, ll x) { if (st > hi || lo > fn) return ; if ( st <= lo && hi <= fn) { P -> Max += x; P -> Has = 1; return ; } if (!P -> l) P -> l = new Node(); if (!P -> r) P -> r = new Node(); mid = (lo + hi)/2; if ( P -> Has == 1) { P -> l -> Has = 1; P -> r -> Has = 1; P -> Has = 0; P -> l -> Max = P -> Max; P -> r -> Max = P -> Max; } Change(P -> l, lo, mid, st, fn, x); Change(P -> r, mid + 1, hi, st, fn, x); P -> Max = max ( P -> l -> Max, P -> r -> Max); } ll Find(Node *P, ll lo, ll hi, ll st, ll fn) { if (st > hi || lo > fn) return 0; if ( st <= lo && hi <= fn) { return P -> Max; } if (!P -> l) P -> l = new Node(); if (!P -> r) P -> r = new Node(); mid = (lo + hi)/2; if ( P -> Has == 1) { P -> l -> Has = 1; P -> r -> Has = 1; P -> Has = 0; P -> l -> Max = P -> Max; P -> r -> Max = P -> Max; } Find(P -> l, lo, mid, st, fn); Find(P -> r, mid + 1, hi, st, fn); P -> Max = max ( P -> l -> Max, P -> r -> Max); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); ll t, n, m, ans, s, sum, x, y, r, p, i, j; cin >> n; vector < pair < ll, ll > > v; Node *Tre = new Node(); for (i = 1; i <= n; i ++) { cin >> x >> y; v.push_back(make_pair(x, y)); } ans= 0; v.push_back(make_pair(0, 0)); sort(v.begin(), v.end()); for (i =1; i < v.size(); i ++) { s = v[i].second - (v[i].first - v[i - 1].first); Change(Tre, 1, n, 1, i - 1, ll((v[i - 1].first -v[i].first))); Change(Tre, 1, n, 1, i, (v[i].second)); ans = max (ans, Tre -> Max); } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 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 | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 600 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 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 | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 600 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 4 ms | 1116 KB | Output is correct |
28 | Correct | 3 ms | 1116 KB | Output is correct |
29 | Correct | 4 ms | 1112 KB | Output is correct |
30 | Correct | 4 ms | 1112 KB | Output is correct |
31 | Correct | 3 ms | 1116 KB | Output is correct |
32 | Correct | 3 ms | 976 KB | Output is correct |
33 | Correct | 3 ms | 1116 KB | Output is correct |
34 | Correct | 3 ms | 928 KB | Output is correct |
35 | Correct | 3 ms | 1116 KB | Output is correct |
36 | Correct | 3 ms | 1116 KB | Output is correct |
37 | Correct | 3 ms | 1116 KB | Output is correct |
38 | Correct | 3 ms | 1116 KB | Output is correct |
39 | Correct | 4 ms | 1112 KB | Output is correct |
40 | Correct | 3 ms | 1368 KB | Output is correct |
41 | Correct | 3 ms | 1112 KB | Output is correct |
42 | Correct | 3 ms | 1116 KB | Output is correct |
43 | Correct | 3 ms | 1116 KB | Output is correct |
44 | Correct | 3 ms | 1116 KB | Output is correct |
45 | Correct | 3 ms | 976 KB | Output is correct |
46 | Correct | 3 ms | 1116 KB | Output is correct |
47 | Correct | 3 ms | 1116 KB | Output is correct |
48 | Correct | 3 ms | 1116 KB | Output is correct |
49 | Correct | 3 ms | 1116 KB | Output is correct |
50 | Correct | 3 ms | 1116 KB | Output is correct |
51 | Correct | 3 ms | 1116 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 344 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 | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 600 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 4 ms | 1116 KB | Output is correct |
28 | Correct | 3 ms | 1116 KB | Output is correct |
29 | Correct | 4 ms | 1112 KB | Output is correct |
30 | Correct | 4 ms | 1112 KB | Output is correct |
31 | Correct | 3 ms | 1116 KB | Output is correct |
32 | Correct | 3 ms | 976 KB | Output is correct |
33 | Correct | 3 ms | 1116 KB | Output is correct |
34 | Correct | 3 ms | 928 KB | Output is correct |
35 | Correct | 3 ms | 1116 KB | Output is correct |
36 | Correct | 3 ms | 1116 KB | Output is correct |
37 | Correct | 3 ms | 1116 KB | Output is correct |
38 | Correct | 3 ms | 1116 KB | Output is correct |
39 | Correct | 4 ms | 1112 KB | Output is correct |
40 | Correct | 3 ms | 1368 KB | Output is correct |
41 | Correct | 3 ms | 1112 KB | Output is correct |
42 | Correct | 3 ms | 1116 KB | Output is correct |
43 | Correct | 3 ms | 1116 KB | Output is correct |
44 | Correct | 3 ms | 1116 KB | Output is correct |
45 | Correct | 3 ms | 976 KB | Output is correct |
46 | Correct | 3 ms | 1116 KB | Output is correct |
47 | Correct | 3 ms | 1116 KB | Output is correct |
48 | Correct | 3 ms | 1116 KB | Output is correct |
49 | Correct | 3 ms | 1116 KB | Output is correct |
50 | Correct | 3 ms | 1116 KB | Output is correct |
51 | Correct | 3 ms | 1116 KB | Output is correct |
52 | Correct | 289 ms | 68256 KB | Output is correct |
53 | Correct | 282 ms | 67808 KB | Output is correct |
54 | Correct | 282 ms | 67980 KB | Output is correct |
55 | Correct | 287 ms | 67692 KB | Output is correct |
56 | Correct | 287 ms | 67668 KB | Output is correct |
57 | Correct | 285 ms | 67724 KB | Output is correct |
58 | Correct | 285 ms | 67764 KB | Output is correct |
59 | Correct | 286 ms | 67960 KB | Output is correct |
60 | Correct | 289 ms | 67740 KB | Output is correct |
61 | Correct | 292 ms | 68024 KB | Output is correct |
62 | Correct | 286 ms | 67768 KB | Output is correct |
63 | Correct | 293 ms | 67868 KB | Output is correct |
64 | Correct | 283 ms | 67660 KB | Output is correct |
65 | Correct | 284 ms | 67952 KB | Output is correct |
66 | Correct | 291 ms | 67768 KB | Output is correct |
67 | Correct | 283 ms | 67864 KB | Output is correct |
68 | Correct | 289 ms | 67796 KB | Output is correct |