답안 #633488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633488 2022-08-22T14:53:57 Z Astrayt Team Contest (JOI22_team) C++17
100 / 100
111 ms 22916 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 1 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 0 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 1 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 0 ms 340 KB Output is correct
26 Correct 4 ms 980 KB Output is correct
27 Correct 3 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 2 ms 824 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 3 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 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 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 62 ms 22776 KB Output is correct
12 Correct 34 ms 13732 KB Output is correct
13 Correct 38 ms 16860 KB Output is correct
14 Correct 53 ms 22708 KB Output is correct
15 Correct 53 ms 22792 KB Output is correct
16 Correct 57 ms 22692 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 1 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 62 ms 22776 KB Output is correct
12 Correct 34 ms 13732 KB Output is correct
13 Correct 38 ms 16860 KB Output is correct
14 Correct 53 ms 22708 KB Output is correct
15 Correct 53 ms 22792 KB Output is correct
16 Correct 57 ms 22692 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 60 ms 22688 KB Output is correct
23 Correct 61 ms 22628 KB Output is correct
24 Correct 41 ms 14920 KB Output is correct
25 Correct 65 ms 22752 KB Output is correct
26 Correct 54 ms 22760 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 1 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 62 ms 22776 KB Output is correct
12 Correct 34 ms 13732 KB Output is correct
13 Correct 38 ms 16860 KB Output is correct
14 Correct 53 ms 22708 KB Output is correct
15 Correct 53 ms 22792 KB Output is correct
16 Correct 57 ms 22692 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 60 ms 22688 KB Output is correct
23 Correct 61 ms 22628 KB Output is correct
24 Correct 41 ms 14920 KB Output is correct
25 Correct 65 ms 22752 KB Output is correct
26 Correct 54 ms 22760 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 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 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 70 ms 22444 KB Output is correct
35 Correct 61 ms 22112 KB Output is correct
36 Correct 65 ms 22680 KB Output is correct
37 Correct 70 ms 22700 KB Output is correct
38 Correct 63 ms 22592 KB Output is correct
39 Correct 33 ms 12476 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 1 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 62 ms 22776 KB Output is correct
12 Correct 34 ms 13732 KB Output is correct
13 Correct 38 ms 16860 KB Output is correct
14 Correct 53 ms 22708 KB Output is correct
15 Correct 53 ms 22792 KB Output is correct
16 Correct 57 ms 22692 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 60 ms 22688 KB Output is correct
23 Correct 61 ms 22628 KB Output is correct
24 Correct 41 ms 14920 KB Output is correct
25 Correct 65 ms 22752 KB Output is correct
26 Correct 54 ms 22760 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 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 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 70 ms 22444 KB Output is correct
35 Correct 61 ms 22112 KB Output is correct
36 Correct 65 ms 22680 KB Output is correct
37 Correct 70 ms 22700 KB Output is correct
38 Correct 63 ms 22592 KB Output is correct
39 Correct 33 ms 12476 KB Output is correct
40 Correct 2 ms 852 KB Output is correct
41 Correct 2 ms 960 KB Output is correct
42 Correct 2 ms 980 KB Output is correct
43 Correct 3 ms 980 KB Output is correct
44 Correct 74 ms 22776 KB Output is correct
45 Correct 74 ms 22684 KB Output is correct
46 Correct 76 ms 22700 KB Output is correct
47 Correct 75 ms 22728 KB Output is correct
48 Correct 75 ms 22680 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 1 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 0 ms 340 KB Output is correct
26 Correct 4 ms 980 KB Output is correct
27 Correct 3 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 2 ms 824 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 3 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 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 0 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 1 ms 212 KB Output is correct
50 Correct 62 ms 22776 KB Output is correct
51 Correct 34 ms 13732 KB Output is correct
52 Correct 38 ms 16860 KB Output is correct
53 Correct 53 ms 22708 KB Output is correct
54 Correct 53 ms 22792 KB Output is correct
55 Correct 57 ms 22692 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 596 KB Output is correct
61 Correct 60 ms 22688 KB Output is correct
62 Correct 61 ms 22628 KB Output is correct
63 Correct 41 ms 14920 KB Output is correct
64 Correct 65 ms 22752 KB Output is correct
65 Correct 54 ms 22760 KB Output is correct
66 Correct 0 ms 340 KB Output is correct
67 Correct 0 ms 340 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 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 70 ms 22444 KB Output is correct
74 Correct 61 ms 22112 KB Output is correct
75 Correct 65 ms 22680 KB Output is correct
76 Correct 70 ms 22700 KB Output is correct
77 Correct 63 ms 22592 KB Output is correct
78 Correct 33 ms 12476 KB Output is correct
79 Correct 2 ms 852 KB Output is correct
80 Correct 2 ms 960 KB Output is correct
81 Correct 2 ms 980 KB Output is correct
82 Correct 3 ms 980 KB Output is correct
83 Correct 74 ms 22776 KB Output is correct
84 Correct 74 ms 22684 KB Output is correct
85 Correct 76 ms 22700 KB Output is correct
86 Correct 75 ms 22728 KB Output is correct
87 Correct 75 ms 22680 KB Output is correct
88 Correct 90 ms 22748 KB Output is correct
89 Correct 99 ms 22916 KB Output is correct
90 Correct 89 ms 22896 KB Output is correct
91 Correct 99 ms 22704 KB Output is correct
92 Correct 92 ms 22876 KB Output is correct
93 Correct 87 ms 22676 KB Output is correct
94 Correct 85 ms 22724 KB Output is correct
95 Correct 74 ms 22720 KB Output is correct
96 Correct 111 ms 22680 KB Output is correct
97 Correct 73 ms 22840 KB Output is correct
98 Correct 59 ms 22684 KB Output is correct
99 Correct 98 ms 22724 KB Output is correct