답안 #545057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545057 2022-04-03T13:20:06 Z baluteshih Team Contest (JOI22_team) C++14
100 / 100
140 ms 16048 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back

struct Node {
    int x, y, z;
    bool operator<(const Node &a) const {
        return x > a.x;
    }
} arr[150005];

multiset<pii> yst, zst;

void insert(multiset<pii> &st, pii &mx, pii val) {
    auto p = st.lower_bound(pii(val.X, val.Y));
    while (p != st.end() && p->Y <= val.Y)
        p = st.erase(p);
    if (p == st.begin())
        st.insert(val);
    else {
        if (prev(p)->Y < val.Y)
            st.insert(val);
        else if (prev(p)->Y > val.Y) {
            if (mx.X + mx.Y < val.X + prev(p)->Y)
                mx = pii(val.X, prev(p)->Y);
        }
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    int ans = -1;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> arr[i].x >> arr[i].y >> arr[i].z;
    sort(arr + 1, arr + n + 1);
    pii ymx = pii(-1, -1);
    pii zmx = pii(-1, -1);
    for (int i = n, j = n; i >= 1; --i) {
        while (arr[j].x < arr[i].x) {
            insert(yst, ymx, pii(arr[j].y, arr[j].z));
            insert(zst, zmx, pii(arr[j].z, arr[j].y));
            /*cout << "insert (" << arr[j].y << ", " << arr[j].z << "),\n";
            cout << "ymx = (" << ymx.X << ", " << ymx.Y << ")\n";
            cout << "zmx = (" << zmx.Y << ", " << zmx.X << ")\n";*/
            --j;
        }
        if (ymx.X > arr[i].y && ymx.Y > arr[i].z)
            ans = max(ans, arr[i].x + ymx.X + ymx.Y);
        if (zmx.X > arr[i].z && zmx.Y > arr[i].y)
            ans = max(ans, arr[i].x + zmx.X + zmx.Y);
    }
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 248 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 248 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 3 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 35 ms 2080 KB Output is correct
12 Correct 23 ms 1492 KB Output is correct
13 Correct 29 ms 1700 KB Output is correct
14 Correct 31 ms 2036 KB Output is correct
15 Correct 32 ms 2032 KB Output is correct
16 Correct 30 ms 2076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 35 ms 2080 KB Output is correct
12 Correct 23 ms 1492 KB Output is correct
13 Correct 29 ms 1700 KB Output is correct
14 Correct 31 ms 2036 KB Output is correct
15 Correct 32 ms 2032 KB Output is correct
16 Correct 30 ms 2076 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 39 ms 2072 KB Output is correct
23 Correct 37 ms 2028 KB Output is correct
24 Correct 32 ms 1492 KB Output is correct
25 Correct 42 ms 2012 KB Output is correct
26 Correct 29 ms 2064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 35 ms 2080 KB Output is correct
12 Correct 23 ms 1492 KB Output is correct
13 Correct 29 ms 1700 KB Output is correct
14 Correct 31 ms 2036 KB Output is correct
15 Correct 32 ms 2032 KB Output is correct
16 Correct 30 ms 2076 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 39 ms 2072 KB Output is correct
23 Correct 37 ms 2028 KB Output is correct
24 Correct 32 ms 1492 KB Output is correct
25 Correct 42 ms 2012 KB Output is correct
26 Correct 29 ms 2064 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 37 ms 1940 KB Output is correct
35 Correct 43 ms 1928 KB Output is correct
36 Correct 45 ms 2060 KB Output is correct
37 Correct 60 ms 1996 KB Output is correct
38 Correct 35 ms 1952 KB Output is correct
39 Correct 17 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 35 ms 2080 KB Output is correct
12 Correct 23 ms 1492 KB Output is correct
13 Correct 29 ms 1700 KB Output is correct
14 Correct 31 ms 2036 KB Output is correct
15 Correct 32 ms 2032 KB Output is correct
16 Correct 30 ms 2076 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 39 ms 2072 KB Output is correct
23 Correct 37 ms 2028 KB Output is correct
24 Correct 32 ms 1492 KB Output is correct
25 Correct 42 ms 2012 KB Output is correct
26 Correct 29 ms 2064 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 37 ms 1940 KB Output is correct
35 Correct 43 ms 1928 KB Output is correct
36 Correct 45 ms 2060 KB Output is correct
37 Correct 60 ms 1996 KB Output is correct
38 Correct 35 ms 1952 KB Output is correct
39 Correct 17 ms 1388 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 3 ms 468 KB Output is correct
44 Correct 42 ms 2068 KB Output is correct
45 Correct 70 ms 2100 KB Output is correct
46 Correct 63 ms 2272 KB Output is correct
47 Correct 65 ms 2180 KB Output is correct
48 Correct 36 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 248 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 3 ms 724 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 3 ms 468 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 35 ms 2080 KB Output is correct
51 Correct 23 ms 1492 KB Output is correct
52 Correct 29 ms 1700 KB Output is correct
53 Correct 31 ms 2036 KB Output is correct
54 Correct 32 ms 2032 KB Output is correct
55 Correct 30 ms 2076 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 39 ms 2072 KB Output is correct
62 Correct 37 ms 2028 KB Output is correct
63 Correct 32 ms 1492 KB Output is correct
64 Correct 42 ms 2012 KB Output is correct
65 Correct 29 ms 2064 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 340 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 37 ms 1940 KB Output is correct
74 Correct 43 ms 1928 KB Output is correct
75 Correct 45 ms 2060 KB Output is correct
76 Correct 60 ms 1996 KB Output is correct
77 Correct 35 ms 1952 KB Output is correct
78 Correct 17 ms 1388 KB Output is correct
79 Correct 2 ms 340 KB Output is correct
80 Correct 2 ms 340 KB Output is correct
81 Correct 2 ms 468 KB Output is correct
82 Correct 3 ms 468 KB Output is correct
83 Correct 42 ms 2068 KB Output is correct
84 Correct 70 ms 2100 KB Output is correct
85 Correct 63 ms 2272 KB Output is correct
86 Correct 65 ms 2180 KB Output is correct
87 Correct 36 ms 1996 KB Output is correct
88 Correct 55 ms 2004 KB Output is correct
89 Correct 86 ms 3404 KB Output is correct
90 Correct 65 ms 2252 KB Output is correct
91 Correct 106 ms 3072 KB Output is correct
92 Correct 65 ms 2624 KB Output is correct
93 Correct 92 ms 3900 KB Output is correct
94 Correct 94 ms 3744 KB Output is correct
95 Correct 46 ms 2024 KB Output is correct
96 Correct 140 ms 16048 KB Output is correct
97 Correct 40 ms 1960 KB Output is correct
98 Correct 74 ms 6688 KB Output is correct
99 Correct 75 ms 6760 KB Output is correct