답안 #567706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567706 2022-05-24T05:36:12 Z tqbfjotld Team Contest (JOI22_team) C++14
100 / 100
509 ms 27016 KB
#include <bits/stdc++.h>
using namespace std;

int X[150005];
int Y[150005];
int Z[150005];
set<pair<int,int> > Xv, Yv, Zv;

void remv(int x){
    Xv.erase(Xv.lower_bound({X[x],x}));
    Yv.erase(Yv.lower_bound({Y[x],x}));
    Zv.erase(Zv.lower_bound({Z[x],x}));
}

void getTop(int&a, int&b, int&c){
    if (Xv.size()<3){
        a = -1; b = -1; c = -1;
        return;
    }
    a = (*--Xv.end()).second;
    b = (*--Yv.end()).second;
    c = (*--Zv.end()).second;
}

bool checkTop(int a, int b, int c){
    if (a==b && b==c){
        remv(a);
        return false;
    }
    if (a==b){
        remv(a);
        return false;
    }
    else if (b==c){
        remv(b);
        return false;
    }
    else if (a==c){
        remv(a);
        return false;
    }
    if (Y[a]>=Y[b] || Z[a]>=Z[c]){
        remv(a);
        return false;
    }
    if (X[b]>=X[a] || Z[b]>=Z[c]){
        remv(b);
        return false;
    }
    if (X[c]>=X[a] || Y[c]>=Y[b]){
        remv(c);
        return false;
    }
    return true;
}

int main(){
    int n;
    scanf("%d",&n);
    for (int x = 0; x<n; x++){
        scanf("%d%d%d",&X[x],&Y[x],&Z[x]);
    }
    for (int x = 0; x<n; x++){
        Xv.insert({X[x],x});
        Yv.insert({Y[x],x});
        Zv.insert({Z[x],x});
    }
    int a,b,c;
    while (true){
        getTop(a,b,c);
        if (a==-1){
            printf("-1");
            return 0;
        }
        if (checkTop(a,b,c)){
            printf("%d",X[a]+Y[b]+Z[c]);
            return 0;
        }
    }

}

Compilation message

team.cpp: In function 'int main()':
team.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
team.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         scanf("%d%d%d",&X[x],&Y[x],&Z[x]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 312 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 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 1 ms 224 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 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 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 312 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 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 1 ms 224 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 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 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 4 ms 972 KB Output is correct
27 Correct 6 ms 980 KB Output is correct
28 Correct 5 ms 980 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 5 ms 724 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 6 ms 844 KB Output is correct
33 Correct 4 ms 980 KB Output is correct
34 Correct 5 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 2 ms 448 KB Output is correct
37 Correct 3 ms 964 KB Output is correct
38 Correct 4 ms 932 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 193 ms 23736 KB Output is correct
12 Correct 157 ms 16004 KB Output is correct
13 Correct 143 ms 19780 KB Output is correct
14 Correct 238 ms 24012 KB Output is correct
15 Correct 200 ms 23612 KB Output is correct
16 Correct 178 ms 23780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 193 ms 23736 KB Output is correct
12 Correct 157 ms 16004 KB Output is correct
13 Correct 143 ms 19780 KB Output is correct
14 Correct 238 ms 24012 KB Output is correct
15 Correct 200 ms 23612 KB Output is correct
16 Correct 178 ms 23780 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 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 2 ms 596 KB Output is correct
22 Correct 216 ms 23904 KB Output is correct
23 Correct 243 ms 23472 KB Output is correct
24 Correct 258 ms 17484 KB Output is correct
25 Correct 342 ms 24056 KB Output is correct
26 Correct 179 ms 24196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 193 ms 23736 KB Output is correct
12 Correct 157 ms 16004 KB Output is correct
13 Correct 143 ms 19780 KB Output is correct
14 Correct 238 ms 24012 KB Output is correct
15 Correct 200 ms 23612 KB Output is correct
16 Correct 178 ms 23780 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 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 2 ms 596 KB Output is correct
22 Correct 216 ms 23904 KB Output is correct
23 Correct 243 ms 23472 KB Output is correct
24 Correct 258 ms 17484 KB Output is correct
25 Correct 342 ms 24056 KB Output is correct
26 Correct 179 ms 24196 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 6 ms 852 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 282 ms 23404 KB Output is correct
35 Correct 303 ms 22060 KB Output is correct
36 Correct 356 ms 24284 KB Output is correct
37 Correct 425 ms 24632 KB Output is correct
38 Correct 188 ms 23984 KB Output is correct
39 Correct 98 ms 14744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 193 ms 23736 KB Output is correct
12 Correct 157 ms 16004 KB Output is correct
13 Correct 143 ms 19780 KB Output is correct
14 Correct 238 ms 24012 KB Output is correct
15 Correct 200 ms 23612 KB Output is correct
16 Correct 178 ms 23780 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 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 2 ms 596 KB Output is correct
22 Correct 216 ms 23904 KB Output is correct
23 Correct 243 ms 23472 KB Output is correct
24 Correct 258 ms 17484 KB Output is correct
25 Correct 342 ms 24056 KB Output is correct
26 Correct 179 ms 24196 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 6 ms 852 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 282 ms 23404 KB Output is correct
35 Correct 303 ms 22060 KB Output is correct
36 Correct 356 ms 24284 KB Output is correct
37 Correct 425 ms 24632 KB Output is correct
38 Correct 188 ms 23984 KB Output is correct
39 Correct 98 ms 14744 KB Output is correct
40 Correct 4 ms 724 KB Output is correct
41 Correct 5 ms 892 KB Output is correct
42 Correct 3 ms 956 KB Output is correct
43 Correct 4 ms 960 KB Output is correct
44 Correct 343 ms 25192 KB Output is correct
45 Correct 482 ms 25164 KB Output is correct
46 Correct 432 ms 24684 KB Output is correct
47 Correct 509 ms 25172 KB Output is correct
48 Correct 251 ms 25092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 312 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 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 1 ms 224 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 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 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 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 4 ms 972 KB Output is correct
27 Correct 6 ms 980 KB Output is correct
28 Correct 5 ms 980 KB Output is correct
29 Correct 10 ms 980 KB Output is correct
30 Correct 5 ms 724 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 6 ms 844 KB Output is correct
33 Correct 4 ms 980 KB Output is correct
34 Correct 5 ms 980 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 2 ms 448 KB Output is correct
37 Correct 3 ms 964 KB Output is correct
38 Correct 4 ms 932 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 300 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 304 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 316 KB Output is correct
48 Correct 1 ms 312 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 193 ms 23736 KB Output is correct
51 Correct 157 ms 16004 KB Output is correct
52 Correct 143 ms 19780 KB Output is correct
53 Correct 238 ms 24012 KB Output is correct
54 Correct 200 ms 23612 KB Output is correct
55 Correct 178 ms 23780 KB Output is correct
56 Correct 1 ms 212 KB Output is correct
57 Correct 1 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 2 ms 596 KB Output is correct
61 Correct 216 ms 23904 KB Output is correct
62 Correct 243 ms 23472 KB Output is correct
63 Correct 258 ms 17484 KB Output is correct
64 Correct 342 ms 24056 KB Output is correct
65 Correct 179 ms 24196 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 6 ms 852 KB Output is correct
71 Correct 1 ms 460 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 282 ms 23404 KB Output is correct
74 Correct 303 ms 22060 KB Output is correct
75 Correct 356 ms 24284 KB Output is correct
76 Correct 425 ms 24632 KB Output is correct
77 Correct 188 ms 23984 KB Output is correct
78 Correct 98 ms 14744 KB Output is correct
79 Correct 4 ms 724 KB Output is correct
80 Correct 5 ms 892 KB Output is correct
81 Correct 3 ms 956 KB Output is correct
82 Correct 4 ms 960 KB Output is correct
83 Correct 343 ms 25192 KB Output is correct
84 Correct 482 ms 25164 KB Output is correct
85 Correct 432 ms 24684 KB Output is correct
86 Correct 509 ms 25172 KB Output is correct
87 Correct 251 ms 25092 KB Output is correct
88 Correct 360 ms 26076 KB Output is correct
89 Correct 392 ms 25452 KB Output is correct
90 Correct 374 ms 26988 KB Output is correct
91 Correct 413 ms 24824 KB Output is correct
92 Correct 387 ms 24928 KB Output is correct
93 Correct 484 ms 25872 KB Output is correct
94 Correct 412 ms 25780 KB Output is correct
95 Correct 276 ms 27016 KB Output is correct
96 Correct 211 ms 26656 KB Output is correct
97 Correct 167 ms 25820 KB Output is correct
98 Correct 155 ms 25628 KB Output is correct
99 Correct 172 ms 25572 KB Output is correct