답안 #897874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897874 2024-01-03T22:21:33 Z alexander707070 Team Contest (JOI22_team) C++14
100 / 100
169 ms 8164 KB
#include<bits/stdc++.h>
#define MAXN 150007
using namespace std;

int n;
int a[MAXN],b[MAXN],c[MAXN];

int sa[MAXN],sb[MAXN],sc[MAXN],pta,ptb,ptc;
bool bad[MAXN];

bool cmpa(int x,int y){
    return a[x]<a[y];
}

bool cmpb(int x,int y){
    return b[x]<b[y];
}

bool cmpc(int x,int y){
    return c[x]<c[y];
}

int main(){

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];

        sa[i]=sb[i]=sc[i]=i;
    }
    sort(sa+1,sa+n+1,cmpa);
    sort(sb+1,sb+n+1,cmpb);
    sort(sc+1,sc+n+1,cmpc);

    pta=ptb=ptc=n;

    while(pta>=1 and ptb>=1 and ptc>=1){

        if(b[sa[pta]]==b[sb[ptb]] or c[sa[pta]]==c[sc[ptc]]){
            bad[sa[pta]]=true; pta--;
        }else if(a[sb[ptb]]==a[sa[pta]] or c[sb[ptb]]==c[sc[ptc]]){
            bad[sb[ptb]]=true; ptb--;
        }else if(b[sb[ptb]]==b[sc[ptc]] or a[sa[pta]]==a[sc[ptc]]){
            bad[sc[ptc]]=true; ptc--;
        }else break;

        while(bad[sa[pta]])pta--;
        while(bad[sb[ptb]])ptb--;
        while(bad[sc[ptc]])ptc--;
    }

    if(pta==0 or ptb==0 or ptc==0){
        cout<<"-1\n";
    }else{
        cout<<a[sa[pta]]+b[sb[ptb]]+c[sc[ptc]]<<"\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2408 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2408 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 5 ms 2500 KB Output is correct
27 Correct 5 ms 2652 KB Output is correct
28 Correct 5 ms 2652 KB Output is correct
29 Correct 5 ms 2648 KB Output is correct
30 Correct 3 ms 2532 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 3 ms 2396 KB Output is correct
33 Correct 4 ms 2652 KB Output is correct
34 Correct 4 ms 2652 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 3 ms 2396 KB Output is correct
38 Correct 4 ms 2396 KB Output is correct
39 Correct 2 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 66 ms 4712 KB Output is correct
12 Correct 44 ms 4128 KB Output is correct
13 Correct 51 ms 4440 KB Output is correct
14 Correct 67 ms 4948 KB Output is correct
15 Correct 64 ms 4944 KB Output is correct
16 Correct 61 ms 4724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 66 ms 4712 KB Output is correct
12 Correct 44 ms 4128 KB Output is correct
13 Correct 51 ms 4440 KB Output is correct
14 Correct 67 ms 4948 KB Output is correct
15 Correct 64 ms 4944 KB Output is correct
16 Correct 61 ms 4724 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 76 ms 4968 KB Output is correct
23 Correct 68 ms 4948 KB Output is correct
24 Correct 58 ms 4320 KB Output is correct
25 Correct 84 ms 5204 KB Output is correct
26 Correct 67 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 66 ms 4712 KB Output is correct
12 Correct 44 ms 4128 KB Output is correct
13 Correct 51 ms 4440 KB Output is correct
14 Correct 67 ms 4948 KB Output is correct
15 Correct 64 ms 4944 KB Output is correct
16 Correct 61 ms 4724 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 76 ms 4968 KB Output is correct
23 Correct 68 ms 4948 KB Output is correct
24 Correct 58 ms 4320 KB Output is correct
25 Correct 84 ms 5204 KB Output is correct
26 Correct 67 ms 4940 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2648 KB Output is correct
34 Correct 89 ms 5204 KB Output is correct
35 Correct 86 ms 5256 KB Output is correct
36 Correct 95 ms 5468 KB Output is correct
37 Correct 98 ms 5572 KB Output is correct
38 Correct 81 ms 5460 KB Output is correct
39 Correct 48 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2756 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 66 ms 4712 KB Output is correct
12 Correct 44 ms 4128 KB Output is correct
13 Correct 51 ms 4440 KB Output is correct
14 Correct 67 ms 4948 KB Output is correct
15 Correct 64 ms 4944 KB Output is correct
16 Correct 61 ms 4724 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 76 ms 4968 KB Output is correct
23 Correct 68 ms 4948 KB Output is correct
24 Correct 58 ms 4320 KB Output is correct
25 Correct 84 ms 5204 KB Output is correct
26 Correct 67 ms 4940 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2648 KB Output is correct
34 Correct 89 ms 5204 KB Output is correct
35 Correct 86 ms 5256 KB Output is correct
36 Correct 95 ms 5468 KB Output is correct
37 Correct 98 ms 5572 KB Output is correct
38 Correct 81 ms 5460 KB Output is correct
39 Correct 48 ms 4188 KB Output is correct
40 Correct 3 ms 2396 KB Output is correct
41 Correct 3 ms 2396 KB Output is correct
42 Correct 3 ms 2392 KB Output is correct
43 Correct 4 ms 2396 KB Output is correct
44 Correct 117 ms 5948 KB Output is correct
45 Correct 125 ms 6052 KB Output is correct
46 Correct 117 ms 5960 KB Output is correct
47 Correct 121 ms 6424 KB Output is correct
48 Correct 97 ms 5968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2408 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 5 ms 2500 KB Output is correct
27 Correct 5 ms 2652 KB Output is correct
28 Correct 5 ms 2652 KB Output is correct
29 Correct 5 ms 2648 KB Output is correct
30 Correct 3 ms 2532 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 3 ms 2396 KB Output is correct
33 Correct 4 ms 2652 KB Output is correct
34 Correct 4 ms 2652 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 3 ms 2396 KB Output is correct
38 Correct 4 ms 2396 KB Output is correct
39 Correct 2 ms 2648 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2756 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 66 ms 4712 KB Output is correct
51 Correct 44 ms 4128 KB Output is correct
52 Correct 51 ms 4440 KB Output is correct
53 Correct 67 ms 4948 KB Output is correct
54 Correct 64 ms 4944 KB Output is correct
55 Correct 61 ms 4724 KB Output is correct
56 Correct 0 ms 2396 KB Output is correct
57 Correct 0 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 2 ms 2396 KB Output is correct
61 Correct 76 ms 4968 KB Output is correct
62 Correct 68 ms 4948 KB Output is correct
63 Correct 58 ms 4320 KB Output is correct
64 Correct 84 ms 5204 KB Output is correct
65 Correct 67 ms 4940 KB Output is correct
66 Correct 1 ms 2396 KB Output is correct
67 Correct 1 ms 2392 KB Output is correct
68 Correct 1 ms 2396 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 3 ms 2396 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2648 KB Output is correct
73 Correct 89 ms 5204 KB Output is correct
74 Correct 86 ms 5256 KB Output is correct
75 Correct 95 ms 5468 KB Output is correct
76 Correct 98 ms 5572 KB Output is correct
77 Correct 81 ms 5460 KB Output is correct
78 Correct 48 ms 4188 KB Output is correct
79 Correct 3 ms 2396 KB Output is correct
80 Correct 3 ms 2396 KB Output is correct
81 Correct 3 ms 2392 KB Output is correct
82 Correct 4 ms 2396 KB Output is correct
83 Correct 117 ms 5948 KB Output is correct
84 Correct 125 ms 6052 KB Output is correct
85 Correct 117 ms 5960 KB Output is correct
86 Correct 121 ms 6424 KB Output is correct
87 Correct 97 ms 5968 KB Output is correct
88 Correct 167 ms 7804 KB Output is correct
89 Correct 166 ms 7852 KB Output is correct
90 Correct 163 ms 7764 KB Output is correct
91 Correct 169 ms 8164 KB Output is correct
92 Correct 131 ms 6480 KB Output is correct
93 Correct 142 ms 6740 KB Output is correct
94 Correct 143 ms 6740 KB Output is correct
95 Correct 160 ms 7764 KB Output is correct
96 Correct 163 ms 7812 KB Output is correct
97 Correct 130 ms 7960 KB Output is correct
98 Correct 109 ms 6500 KB Output is correct
99 Correct 153 ms 6480 KB Output is correct