답안 #551659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
551659 2022-04-21T09:25:05 Z kshitij_sodani Team Contest (JOI22_team) C++14
64 / 100
2000 ms 28228 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define a first
#define b second
#define pb push_back
#define endl '\n'
const llo mod=1e9+7;
llo n;
llo it[200001][3];
multiset<llo> pre[3];
llo ma[3];
llo vis[200001];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;

	for(llo i=0;i<n;i++){
		for(llo j=0;j<3;j++){
			cin>>it[i][j];
			pre[j].insert(it[i][j]);
		}
	}
	while(true){
		if(pre[0].size()<3){
			cout<<-1<<endl;
			return 0;
		}
		for(llo i=0;i<3;i++){
			auto j=pre[i].end();
			j--;
			ma[i]=(*j);
		}
		llo st=0;
		for(llo i=0;i<n;i++){
			llo co=0;
			if(vis[i]){
				continue;
			}

			for(llo j=0;j<3;j++){
				if(it[i][j]==ma[j]){
					co++;
				}
			}
			if(co>1){
				for(llo j=0;j<3;j++){
					auto ii=pre[j].find(it[i][j]);
					pre[j].erase(ii);

				}
				vis[i]=1;
				st++;
			}
		}
		if(st==0){
			cout<<ma[0]+ma[2]+ma[1]<<endl;
			return 0;
		}
	}







	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 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 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 344 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 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 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 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 344 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 1036 KB Output is correct
27 Correct 13 ms 980 KB Output is correct
28 Correct 25 ms 1108 KB Output is correct
29 Correct 47 ms 1092 KB Output is correct
30 Correct 19 ms 724 KB Output is correct
31 Correct 11 ms 952 KB Output is correct
32 Correct 10 ms 992 KB Output is correct
33 Correct 4 ms 980 KB Output is correct
34 Correct 73 ms 984 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 980 KB Output is correct
38 Correct 18 ms 1064 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 172 ms 26668 KB Output is correct
12 Correct 126 ms 17880 KB Output is correct
13 Correct 125 ms 22276 KB Output is correct
14 Correct 211 ms 27012 KB Output is correct
15 Correct 153 ms 26464 KB Output is correct
16 Correct 143 ms 26656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 172 ms 26668 KB Output is correct
12 Correct 126 ms 17880 KB Output is correct
13 Correct 125 ms 22276 KB Output is correct
14 Correct 211 ms 27012 KB Output is correct
15 Correct 153 ms 26464 KB Output is correct
16 Correct 143 ms 26656 KB Output is correct
17 Correct 0 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 2 ms 604 KB Output is correct
22 Correct 189 ms 26944 KB Output is correct
23 Correct 203 ms 26296 KB Output is correct
24 Correct 184 ms 19612 KB Output is correct
25 Correct 266 ms 27212 KB Output is correct
26 Correct 166 ms 27084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 172 ms 26668 KB Output is correct
12 Correct 126 ms 17880 KB Output is correct
13 Correct 125 ms 22276 KB Output is correct
14 Correct 211 ms 27012 KB Output is correct
15 Correct 153 ms 26464 KB Output is correct
16 Correct 143 ms 26656 KB Output is correct
17 Correct 0 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 2 ms 604 KB Output is correct
22 Correct 189 ms 26944 KB Output is correct
23 Correct 203 ms 26296 KB Output is correct
24 Correct 184 ms 19612 KB Output is correct
25 Correct 266 ms 27212 KB Output is correct
26 Correct 166 ms 27084 KB Output is correct
27 Correct 1 ms 388 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 12 ms 980 KB Output is correct
32 Correct 1 ms 476 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 243 ms 25020 KB Output is correct
35 Correct 507 ms 24592 KB Output is correct
36 Correct 634 ms 27244 KB Output is correct
37 Correct 765 ms 27560 KB Output is correct
38 Correct 201 ms 26604 KB Output is correct
39 Correct 156 ms 16380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 172 ms 26668 KB Output is correct
12 Correct 126 ms 17880 KB Output is correct
13 Correct 125 ms 22276 KB Output is correct
14 Correct 211 ms 27012 KB Output is correct
15 Correct 153 ms 26464 KB Output is correct
16 Correct 143 ms 26656 KB Output is correct
17 Correct 0 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 2 ms 604 KB Output is correct
22 Correct 189 ms 26944 KB Output is correct
23 Correct 203 ms 26296 KB Output is correct
24 Correct 184 ms 19612 KB Output is correct
25 Correct 266 ms 27212 KB Output is correct
26 Correct 166 ms 27084 KB Output is correct
27 Correct 1 ms 388 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 12 ms 980 KB Output is correct
32 Correct 1 ms 476 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 243 ms 25020 KB Output is correct
35 Correct 507 ms 24592 KB Output is correct
36 Correct 634 ms 27244 KB Output is correct
37 Correct 765 ms 27560 KB Output is correct
38 Correct 201 ms 26604 KB Output is correct
39 Correct 156 ms 16380 KB Output is correct
40 Correct 19 ms 836 KB Output is correct
41 Correct 10 ms 980 KB Output is correct
42 Correct 3 ms 980 KB Output is correct
43 Correct 20 ms 1052 KB Output is correct
44 Correct 364 ms 27008 KB Output is correct
45 Execution timed out 2071 ms 28228 KB Time limit exceeded
46 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 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 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 344 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 1036 KB Output is correct
27 Correct 13 ms 980 KB Output is correct
28 Correct 25 ms 1108 KB Output is correct
29 Correct 47 ms 1092 KB Output is correct
30 Correct 19 ms 724 KB Output is correct
31 Correct 11 ms 952 KB Output is correct
32 Correct 10 ms 992 KB Output is correct
33 Correct 4 ms 980 KB Output is correct
34 Correct 73 ms 984 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 980 KB Output is correct
38 Correct 18 ms 1064 KB Output is correct
39 Correct 2 ms 596 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 172 ms 26668 KB Output is correct
51 Correct 126 ms 17880 KB Output is correct
52 Correct 125 ms 22276 KB Output is correct
53 Correct 211 ms 27012 KB Output is correct
54 Correct 153 ms 26464 KB Output is correct
55 Correct 143 ms 26656 KB Output is correct
56 Correct 0 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 2 ms 604 KB Output is correct
61 Correct 189 ms 26944 KB Output is correct
62 Correct 203 ms 26296 KB Output is correct
63 Correct 184 ms 19612 KB Output is correct
64 Correct 266 ms 27212 KB Output is correct
65 Correct 166 ms 27084 KB Output is correct
66 Correct 1 ms 388 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 2 ms 340 KB Output is correct
70 Correct 12 ms 980 KB Output is correct
71 Correct 1 ms 476 KB Output is correct
72 Correct 2 ms 468 KB Output is correct
73 Correct 243 ms 25020 KB Output is correct
74 Correct 507 ms 24592 KB Output is correct
75 Correct 634 ms 27244 KB Output is correct
76 Correct 765 ms 27560 KB Output is correct
77 Correct 201 ms 26604 KB Output is correct
78 Correct 156 ms 16380 KB Output is correct
79 Correct 19 ms 836 KB Output is correct
80 Correct 10 ms 980 KB Output is correct
81 Correct 3 ms 980 KB Output is correct
82 Correct 20 ms 1052 KB Output is correct
83 Correct 364 ms 27008 KB Output is correct
84 Execution timed out 2071 ms 28228 KB Time limit exceeded
85 Halted 0 ms 0 KB -