# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
591894 |
2022-07-08T07:05:58 Z |
반딧불(#8422) |
Team Contest (JOI22_team) |
C++17 |
|
605 ms |
28132 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int x[150002], y[150002], z[150002];
vector<pair<int, int> > xVec, yVec, zVec;
bool deleted[150002];
int maxCnt[150002];
multiset<int> xSet, ySet, zSet;
queue<int> que;
void run(vector<pair<int, int> > &vec, int &pnt, multiset<int> &st){
while(pnt < n && (vec[pnt].first >= *st.rbegin() || deleted[vec[pnt].second])){
if(deleted[vec[pnt].second]){
pnt++;
continue;
}
int x = vec[pnt].second;
maxCnt[x]++;
if(maxCnt[x] == 2) que.push(x);
pnt++;
}
}
int main(){
scanf("%d", &n);
for(int i=1; i<=n; i++){
scanf("%d %d %d", &x[i], &y[i], &z[i]);
xVec.push_back(make_pair(x[i], i));
yVec.push_back(make_pair(y[i], i));
zVec.push_back(make_pair(z[i], i));
xSet.insert(x[i]);
ySet.insert(y[i]);
zSet.insert(z[i]);
}
sort(xVec.rbegin(), xVec.rend());
sort(yVec.rbegin(), yVec.rend());
sort(zVec.rbegin(), zVec.rend());
int xpnt = 0, ypnt = 0, zpnt = 0;
int sum = 0;
while(1){
run(xVec, xpnt, xSet);
run(yVec, ypnt, ySet);
run(zVec, zpnt, zSet);
while(!que.empty()){
int tmp = que.front(); que.pop();
deleted[tmp] = 1;
xSet.erase(xSet.find(x[tmp]));
ySet.erase(ySet.find(y[tmp]));
zSet.erase(zSet.find(z[tmp]));
}
if(xpnt+ypnt+zpnt == sum || xSet.empty() || ySet.empty() || zSet.empty()) break;
sum = xpnt+ypnt+zpnt;
}
if(xSet.empty()) printf("-1");
else printf("%d", *xSet.rbegin() + *ySet.rbegin() + *zSet.rbegin());
}
Compilation message
team.cpp: In function 'int main()':
team.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
team.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | scanf("%d %d %d", &x[i], &y[i], &z[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
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 |
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 |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
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 |
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 |
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 |
6 ms |
1108 KB |
Output is correct |
27 |
Correct |
6 ms |
1004 KB |
Output is correct |
28 |
Correct |
5 ms |
980 KB |
Output is correct |
29 |
Correct |
6 ms |
1020 KB |
Output is correct |
30 |
Correct |
4 ms |
724 KB |
Output is correct |
31 |
Correct |
5 ms |
980 KB |
Output is correct |
32 |
Correct |
5 ms |
980 KB |
Output is correct |
33 |
Correct |
5 ms |
980 KB |
Output is correct |
34 |
Correct |
5 ms |
980 KB |
Output is correct |
35 |
Correct |
2 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
3 ms |
980 KB |
Output is correct |
38 |
Correct |
4 ms |
980 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
0 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 |
227 ms |
27496 KB |
Output is correct |
12 |
Correct |
181 ms |
18448 KB |
Output is correct |
13 |
Correct |
157 ms |
22588 KB |
Output is correct |
14 |
Correct |
279 ms |
27548 KB |
Output is correct |
15 |
Correct |
213 ms |
27956 KB |
Output is correct |
16 |
Correct |
168 ms |
27972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
0 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 |
227 ms |
27496 KB |
Output is correct |
12 |
Correct |
181 ms |
18448 KB |
Output is correct |
13 |
Correct |
157 ms |
22588 KB |
Output is correct |
14 |
Correct |
279 ms |
27548 KB |
Output is correct |
15 |
Correct |
213 ms |
27956 KB |
Output is correct |
16 |
Correct |
168 ms |
27972 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 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 |
240 ms |
27368 KB |
Output is correct |
23 |
Correct |
241 ms |
26736 KB |
Output is correct |
24 |
Correct |
218 ms |
19948 KB |
Output is correct |
25 |
Correct |
339 ms |
27532 KB |
Output is correct |
26 |
Correct |
245 ms |
28016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
0 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 |
227 ms |
27496 KB |
Output is correct |
12 |
Correct |
181 ms |
18448 KB |
Output is correct |
13 |
Correct |
157 ms |
22588 KB |
Output is correct |
14 |
Correct |
279 ms |
27548 KB |
Output is correct |
15 |
Correct |
213 ms |
27956 KB |
Output is correct |
16 |
Correct |
168 ms |
27972 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 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 |
240 ms |
27368 KB |
Output is correct |
23 |
Correct |
241 ms |
26736 KB |
Output is correct |
24 |
Correct |
218 ms |
19948 KB |
Output is correct |
25 |
Correct |
339 ms |
27532 KB |
Output is correct |
26 |
Correct |
245 ms |
28016 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 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 |
6 ms |
980 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
304 ms |
26076 KB |
Output is correct |
35 |
Correct |
347 ms |
24920 KB |
Output is correct |
36 |
Correct |
386 ms |
27340 KB |
Output is correct |
37 |
Correct |
447 ms |
27212 KB |
Output is correct |
38 |
Correct |
268 ms |
27416 KB |
Output is correct |
39 |
Correct |
154 ms |
16604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
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 |
0 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 |
227 ms |
27496 KB |
Output is correct |
12 |
Correct |
181 ms |
18448 KB |
Output is correct |
13 |
Correct |
157 ms |
22588 KB |
Output is correct |
14 |
Correct |
279 ms |
27548 KB |
Output is correct |
15 |
Correct |
213 ms |
27956 KB |
Output is correct |
16 |
Correct |
168 ms |
27972 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 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 |
240 ms |
27368 KB |
Output is correct |
23 |
Correct |
241 ms |
26736 KB |
Output is correct |
24 |
Correct |
218 ms |
19948 KB |
Output is correct |
25 |
Correct |
339 ms |
27532 KB |
Output is correct |
26 |
Correct |
245 ms |
28016 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 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 |
6 ms |
980 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
304 ms |
26076 KB |
Output is correct |
35 |
Correct |
347 ms |
24920 KB |
Output is correct |
36 |
Correct |
386 ms |
27340 KB |
Output is correct |
37 |
Correct |
447 ms |
27212 KB |
Output is correct |
38 |
Correct |
268 ms |
27416 KB |
Output is correct |
39 |
Correct |
154 ms |
16604 KB |
Output is correct |
40 |
Correct |
4 ms |
724 KB |
Output is correct |
41 |
Correct |
5 ms |
980 KB |
Output is correct |
42 |
Correct |
4 ms |
980 KB |
Output is correct |
43 |
Correct |
6 ms |
980 KB |
Output is correct |
44 |
Correct |
393 ms |
26912 KB |
Output is correct |
45 |
Correct |
559 ms |
27548 KB |
Output is correct |
46 |
Correct |
568 ms |
27420 KB |
Output is correct |
47 |
Correct |
605 ms |
27344 KB |
Output is correct |
48 |
Correct |
368 ms |
28060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
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 |
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 |
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 |
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 |
6 ms |
1108 KB |
Output is correct |
27 |
Correct |
6 ms |
1004 KB |
Output is correct |
28 |
Correct |
5 ms |
980 KB |
Output is correct |
29 |
Correct |
6 ms |
1020 KB |
Output is correct |
30 |
Correct |
4 ms |
724 KB |
Output is correct |
31 |
Correct |
5 ms |
980 KB |
Output is correct |
32 |
Correct |
5 ms |
980 KB |
Output is correct |
33 |
Correct |
5 ms |
980 KB |
Output is correct |
34 |
Correct |
5 ms |
980 KB |
Output is correct |
35 |
Correct |
2 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
3 ms |
980 KB |
Output is correct |
38 |
Correct |
4 ms |
980 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
1 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 |
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 |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
227 ms |
27496 KB |
Output is correct |
51 |
Correct |
181 ms |
18448 KB |
Output is correct |
52 |
Correct |
157 ms |
22588 KB |
Output is correct |
53 |
Correct |
279 ms |
27548 KB |
Output is correct |
54 |
Correct |
213 ms |
27956 KB |
Output is correct |
55 |
Correct |
168 ms |
27972 KB |
Output is correct |
56 |
Correct |
1 ms |
212 KB |
Output is correct |
57 |
Correct |
0 ms |
212 KB |
Output is correct |
58 |
Correct |
0 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 |
240 ms |
27368 KB |
Output is correct |
62 |
Correct |
241 ms |
26736 KB |
Output is correct |
63 |
Correct |
218 ms |
19948 KB |
Output is correct |
64 |
Correct |
339 ms |
27532 KB |
Output is correct |
65 |
Correct |
245 ms |
28016 KB |
Output is correct |
66 |
Correct |
1 ms |
340 KB |
Output is correct |
67 |
Correct |
1 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 |
6 ms |
980 KB |
Output is correct |
71 |
Correct |
1 ms |
468 KB |
Output is correct |
72 |
Correct |
2 ms |
468 KB |
Output is correct |
73 |
Correct |
304 ms |
26076 KB |
Output is correct |
74 |
Correct |
347 ms |
24920 KB |
Output is correct |
75 |
Correct |
386 ms |
27340 KB |
Output is correct |
76 |
Correct |
447 ms |
27212 KB |
Output is correct |
77 |
Correct |
268 ms |
27416 KB |
Output is correct |
78 |
Correct |
154 ms |
16604 KB |
Output is correct |
79 |
Correct |
4 ms |
724 KB |
Output is correct |
80 |
Correct |
5 ms |
980 KB |
Output is correct |
81 |
Correct |
4 ms |
980 KB |
Output is correct |
82 |
Correct |
6 ms |
980 KB |
Output is correct |
83 |
Correct |
393 ms |
26912 KB |
Output is correct |
84 |
Correct |
559 ms |
27548 KB |
Output is correct |
85 |
Correct |
568 ms |
27420 KB |
Output is correct |
86 |
Correct |
605 ms |
27344 KB |
Output is correct |
87 |
Correct |
368 ms |
28060 KB |
Output is correct |
88 |
Correct |
346 ms |
26696 KB |
Output is correct |
89 |
Correct |
461 ms |
27452 KB |
Output is correct |
90 |
Correct |
371 ms |
27408 KB |
Output is correct |
91 |
Correct |
507 ms |
27400 KB |
Output is correct |
92 |
Correct |
435 ms |
27500 KB |
Output is correct |
93 |
Correct |
470 ms |
27564 KB |
Output is correct |
94 |
Correct |
489 ms |
27416 KB |
Output is correct |
95 |
Correct |
306 ms |
28132 KB |
Output is correct |
96 |
Correct |
295 ms |
27384 KB |
Output is correct |
97 |
Correct |
181 ms |
27960 KB |
Output is correct |
98 |
Correct |
148 ms |
26632 KB |
Output is correct |
99 |
Correct |
216 ms |
27364 KB |
Output is correct |