답안 #633487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633487 2022-08-22T14:53:24 Z Astrayt Team Contest (JOI22_team) C++17
100 / 100
100 ms 26460 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;
        int k = max({v[i].x, v[i].y, v[i].z});
        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();
}

Compilation message

team.cpp: In function 'void solve()':
team.cpp:31:13: warning: unused variable 'k' [-Wunused-variable]
   31 |         int k = max({v[i].x, v[i].y, v[i].z});
      |             ^
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 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 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 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 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 1 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 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 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 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 1 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 3 ms 980 KB Output is correct
28 Correct 4 ms 1108 KB Output is correct
29 Correct 2 ms 980 KB Output is correct
30 Correct 2 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 980 KB Output is correct
34 Correct 2 ms 1100 KB Output is correct
35 Correct 1 ms 452 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 268 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 50 ms 22696 KB Output is correct
12 Correct 44 ms 14304 KB Output is correct
13 Correct 39 ms 17564 KB Output is correct
14 Correct 73 ms 23656 KB Output is correct
15 Correct 54 ms 23604 KB Output is correct
16 Correct 48 ms 23656 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 1 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 268 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 50 ms 22696 KB Output is correct
12 Correct 44 ms 14304 KB Output is correct
13 Correct 39 ms 17564 KB Output is correct
14 Correct 73 ms 23656 KB Output is correct
15 Correct 54 ms 23604 KB Output is correct
16 Correct 48 ms 23656 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 320 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 584 KB Output is correct
22 Correct 60 ms 23844 KB Output is correct
23 Correct 57 ms 23476 KB Output is correct
24 Correct 44 ms 15596 KB Output is correct
25 Correct 60 ms 23872 KB Output is correct
26 Correct 52 ms 23708 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 1 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 268 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 50 ms 22696 KB Output is correct
12 Correct 44 ms 14304 KB Output is correct
13 Correct 39 ms 17564 KB Output is correct
14 Correct 73 ms 23656 KB Output is correct
15 Correct 54 ms 23604 KB Output is correct
16 Correct 48 ms 23656 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 320 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 584 KB Output is correct
22 Correct 60 ms 23844 KB Output is correct
23 Correct 57 ms 23476 KB Output is correct
24 Correct 44 ms 15596 KB Output is correct
25 Correct 60 ms 23872 KB Output is correct
26 Correct 52 ms 23708 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 1 ms 452 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 66 ms 23960 KB Output is correct
35 Correct 70 ms 23656 KB Output is correct
36 Correct 67 ms 24316 KB Output is correct
37 Correct 78 ms 24348 KB Output is correct
38 Correct 57 ms 24068 KB Output is correct
39 Correct 33 ms 13376 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 1 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 268 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 50 ms 22696 KB Output is correct
12 Correct 44 ms 14304 KB Output is correct
13 Correct 39 ms 17564 KB Output is correct
14 Correct 73 ms 23656 KB Output is correct
15 Correct 54 ms 23604 KB Output is correct
16 Correct 48 ms 23656 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 320 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 584 KB Output is correct
22 Correct 60 ms 23844 KB Output is correct
23 Correct 57 ms 23476 KB Output is correct
24 Correct 44 ms 15596 KB Output is correct
25 Correct 60 ms 23872 KB Output is correct
26 Correct 52 ms 23708 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 1 ms 452 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 66 ms 23960 KB Output is correct
35 Correct 70 ms 23656 KB Output is correct
36 Correct 67 ms 24316 KB Output is correct
37 Correct 78 ms 24348 KB Output is correct
38 Correct 57 ms 24068 KB Output is correct
39 Correct 33 ms 13376 KB Output is correct
40 Correct 2 ms 852 KB Output is correct
41 Correct 2 ms 1032 KB Output is correct
42 Correct 2 ms 980 KB Output is correct
43 Correct 2 ms 980 KB Output is correct
44 Correct 82 ms 24768 KB Output is correct
45 Correct 79 ms 24704 KB Output is correct
46 Correct 76 ms 24720 KB Output is correct
47 Correct 93 ms 24860 KB Output is correct
48 Correct 64 ms 24588 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 1 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 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 1 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 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 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 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 0 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 1 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 3 ms 980 KB Output is correct
28 Correct 4 ms 1108 KB Output is correct
29 Correct 2 ms 980 KB Output is correct
30 Correct 2 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 980 KB Output is correct
34 Correct 2 ms 1100 KB Output is correct
35 Correct 1 ms 452 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 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 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 0 ms 268 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 50 ms 22696 KB Output is correct
51 Correct 44 ms 14304 KB Output is correct
52 Correct 39 ms 17564 KB Output is correct
53 Correct 73 ms 23656 KB Output is correct
54 Correct 54 ms 23604 KB Output is correct
55 Correct 48 ms 23656 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 320 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 584 KB Output is correct
61 Correct 60 ms 23844 KB Output is correct
62 Correct 57 ms 23476 KB Output is correct
63 Correct 44 ms 15596 KB Output is correct
64 Correct 60 ms 23872 KB Output is correct
65 Correct 52 ms 23708 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 312 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 320 KB Output is correct
70 Correct 2 ms 980 KB Output is correct
71 Correct 1 ms 452 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 66 ms 23960 KB Output is correct
74 Correct 70 ms 23656 KB Output is correct
75 Correct 67 ms 24316 KB Output is correct
76 Correct 78 ms 24348 KB Output is correct
77 Correct 57 ms 24068 KB Output is correct
78 Correct 33 ms 13376 KB Output is correct
79 Correct 2 ms 852 KB Output is correct
80 Correct 2 ms 1032 KB Output is correct
81 Correct 2 ms 980 KB Output is correct
82 Correct 2 ms 980 KB Output is correct
83 Correct 82 ms 24768 KB Output is correct
84 Correct 79 ms 24704 KB Output is correct
85 Correct 76 ms 24720 KB Output is correct
86 Correct 93 ms 24860 KB Output is correct
87 Correct 64 ms 24588 KB Output is correct
88 Correct 92 ms 26408 KB Output is correct
89 Correct 98 ms 26340 KB Output is correct
90 Correct 97 ms 26304 KB Output is correct
91 Correct 100 ms 26392 KB Output is correct
92 Correct 85 ms 25080 KB Output is correct
93 Correct 90 ms 25360 KB Output is correct
94 Correct 93 ms 25180 KB Output is correct
95 Correct 75 ms 26228 KB Output is correct
96 Correct 96 ms 26312 KB Output is correct
97 Correct 68 ms 26460 KB Output is correct
98 Correct 62 ms 25152 KB Output is correct
99 Correct 98 ms 25112 KB Output is correct