답안 #633490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633490 2022-08-22T15:02:22 Z Astrayt Team Contest (JOI22_team) C++17
100 / 100
98 ms 22788 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define N 100005

struct bev{
    int t, x, y, z;
};
vector<bev> v;

void solve(){
    int n; cin >> n;
    vector<int> ok(n, 1);
    vector<bev> buk[3];
    v.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i].x >> v[i].y >> v[i].z; v[i].t = i;
        buk[0].pb(v[i]);
        buk[1].pb(v[i]);
        buk[2].pb(v[i]);
    }
    sort(buk[0].begin(), buk[0].end(), [](bev a, bev b){return a.x < b.x;});
    sort(buk[1].begin(), buk[1].end(), [](bev a, bev b){return a.y < b.y;});
    sort(buk[2].begin(), buk[2].end(), [](bev a, bev b){return a.z < b.z;});
    int i = n - 1, j = n - 1, k = n - 1, ans = -1;
    while(true){
        while(i >= 0 && !ok[buk[0][i].t]) i--;
        while(j >= 0 && !ok[buk[1][j].t]) j--;
        while(k >= 0 && !ok[buk[2][k].t]) k--;
        if(i < 0 || j < 0 || k < 0) break;
        bev a = buk[0][i], b = buk[1][j], c = buk[2][k];
        bool flag = 1;
        if(a.t == b.t) ok[a.t] = 0, flag = 0;
        else if(b.t == c.t) ok[b.t] = 0, flag = 0;
        else if(a.t == c.t) ok[c.t] = 0, flag = 0;
        if(c.x >= a.x || c.y >= b.y) ok[c.t] = 0, flag = 0;
        if(b.x >= a.x || b.z >= c.z) ok[b.t] = 0, flag = 0;
        if(a.y >= b.y || a.z >= c.z) ok[a.t] = 0, flag = 0;
        if(flag) {
            ans = max(ans, a.x + b.y + c.z);
            break;
        }
    }
    cout << ans;
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 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 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 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 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 980 KB Output is correct
27 Correct 2 ms 976 KB Output is correct
28 Correct 3 ms 980 KB Output is correct
29 Correct 2 ms 976 KB Output is correct
30 Correct 3 ms 852 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 2 ms 980 KB Output is correct
33 Correct 2 ms 852 KB Output is correct
34 Correct 2 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 2 ms 980 KB Output is correct
38 Correct 2 ms 980 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 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 57 ms 22776 KB Output is correct
12 Correct 33 ms 13732 KB Output is correct
13 Correct 36 ms 16796 KB Output is correct
14 Correct 74 ms 22732 KB Output is correct
15 Correct 53 ms 22780 KB Output is correct
16 Correct 49 ms 22708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 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 57 ms 22776 KB Output is correct
12 Correct 33 ms 13732 KB Output is correct
13 Correct 36 ms 16796 KB Output is correct
14 Correct 74 ms 22732 KB Output is correct
15 Correct 53 ms 22780 KB Output is correct
16 Correct 49 ms 22708 KB Output is correct
17 Correct 0 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 0 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 62 ms 22676 KB Output is correct
23 Correct 57 ms 22596 KB Output is correct
24 Correct 40 ms 14884 KB Output is correct
25 Correct 60 ms 22704 KB Output is correct
26 Correct 51 ms 22684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 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 57 ms 22776 KB Output is correct
12 Correct 33 ms 13732 KB Output is correct
13 Correct 36 ms 16796 KB Output is correct
14 Correct 74 ms 22732 KB Output is correct
15 Correct 53 ms 22780 KB Output is correct
16 Correct 49 ms 22708 KB Output is correct
17 Correct 0 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 0 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 62 ms 22676 KB Output is correct
23 Correct 57 ms 22596 KB Output is correct
24 Correct 40 ms 14884 KB Output is correct
25 Correct 60 ms 22704 KB Output is correct
26 Correct 51 ms 22684 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 63 ms 22456 KB Output is correct
35 Correct 59 ms 22212 KB Output is correct
36 Correct 65 ms 22684 KB Output is correct
37 Correct 67 ms 22660 KB Output is correct
38 Correct 57 ms 22572 KB Output is correct
39 Correct 31 ms 12444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 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 57 ms 22776 KB Output is correct
12 Correct 33 ms 13732 KB Output is correct
13 Correct 36 ms 16796 KB Output is correct
14 Correct 74 ms 22732 KB Output is correct
15 Correct 53 ms 22780 KB Output is correct
16 Correct 49 ms 22708 KB Output is correct
17 Correct 0 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 0 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 62 ms 22676 KB Output is correct
23 Correct 57 ms 22596 KB Output is correct
24 Correct 40 ms 14884 KB Output is correct
25 Correct 60 ms 22704 KB Output is correct
26 Correct 51 ms 22684 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 63 ms 22456 KB Output is correct
35 Correct 59 ms 22212 KB Output is correct
36 Correct 65 ms 22684 KB Output is correct
37 Correct 67 ms 22660 KB Output is correct
38 Correct 57 ms 22572 KB Output is correct
39 Correct 31 ms 12444 KB Output is correct
40 Correct 2 ms 852 KB Output is correct
41 Correct 2 ms 980 KB Output is correct
42 Correct 2 ms 980 KB Output is correct
43 Correct 2 ms 980 KB Output is correct
44 Correct 73 ms 22788 KB Output is correct
45 Correct 86 ms 22732 KB Output is correct
46 Correct 75 ms 22684 KB Output is correct
47 Correct 78 ms 22740 KB Output is correct
48 Correct 63 ms 22752 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 1 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 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 980 KB Output is correct
27 Correct 2 ms 976 KB Output is correct
28 Correct 3 ms 980 KB Output is correct
29 Correct 2 ms 976 KB Output is correct
30 Correct 3 ms 852 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 2 ms 980 KB Output is correct
33 Correct 2 ms 852 KB Output is correct
34 Correct 2 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 2 ms 980 KB Output is correct
38 Correct 2 ms 980 KB Output is correct
39 Correct 1 ms 596 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 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 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 57 ms 22776 KB Output is correct
51 Correct 33 ms 13732 KB Output is correct
52 Correct 36 ms 16796 KB Output is correct
53 Correct 74 ms 22732 KB Output is correct
54 Correct 53 ms 22780 KB Output is correct
55 Correct 49 ms 22708 KB Output is correct
56 Correct 0 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 0 ms 340 KB Output is correct
60 Correct 1 ms 596 KB Output is correct
61 Correct 62 ms 22676 KB Output is correct
62 Correct 57 ms 22596 KB Output is correct
63 Correct 40 ms 14884 KB Output is correct
64 Correct 60 ms 22704 KB Output is correct
65 Correct 51 ms 22684 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 0 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 980 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 63 ms 22456 KB Output is correct
74 Correct 59 ms 22212 KB Output is correct
75 Correct 65 ms 22684 KB Output is correct
76 Correct 67 ms 22660 KB Output is correct
77 Correct 57 ms 22572 KB Output is correct
78 Correct 31 ms 12444 KB Output is correct
79 Correct 2 ms 852 KB Output is correct
80 Correct 2 ms 980 KB Output is correct
81 Correct 2 ms 980 KB Output is correct
82 Correct 2 ms 980 KB Output is correct
83 Correct 73 ms 22788 KB Output is correct
84 Correct 86 ms 22732 KB Output is correct
85 Correct 75 ms 22684 KB Output is correct
86 Correct 78 ms 22740 KB Output is correct
87 Correct 63 ms 22752 KB Output is correct
88 Correct 90 ms 22676 KB Output is correct
89 Correct 90 ms 22684 KB Output is correct
90 Correct 86 ms 22760 KB Output is correct
91 Correct 92 ms 22684 KB Output is correct
92 Correct 81 ms 22720 KB Output is correct
93 Correct 94 ms 22752 KB Output is correct
94 Correct 83 ms 22688 KB Output is correct
95 Correct 75 ms 22704 KB Output is correct
96 Correct 88 ms 22684 KB Output is correct
97 Correct 67 ms 22728 KB Output is correct
98 Correct 56 ms 22692 KB Output is correct
99 Correct 98 ms 22744 KB Output is correct