# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
931904 |
2024-02-22T14:24:18 Z |
ace5 |
Team Contest (JOI22_team) |
C++17 |
|
244 ms |
36044 KB |
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int xm[3][n];
vector<vector<pair<int,int>>> x(3,vector<pair<int,int>>(n));
vector<vector<int>> c(n);
vector<int> rem(n,1);
set<pair<int,int>> ck;
vector<int> yk(3);
vector<int> km(3);
for(int i = 0;i < n;++i)
{
cin >> xm[0][i] >> xm[1][i] >> xm[2][i];
x[0][i] = {xm[0][i],i};
x[1][i] = {xm[1][i],i};
x[2][i] = {xm[2][i],i};
}
for(int j =0;j < 3;++j)
{
yk[j] = -1;
sort(x[j].begin(),x[j].end());
for(int u = x[j].size()-1;u >= 0;--u)
{
if(x[j][u].first == x[j].back().first)
{
c[x[j][u].second].push_back(j);
km[j]++;
}
else
{
yk[j] = u;
break;
}
}
}
for(int j = 0;j < n;++j)
{
ck.insert({-int(c[j].size()),j});
}
int ky =n;
while(ck.size())
{
int v = (*ck.begin()).second;
ck.erase(ck.begin());
if(c[v].size() >= 2)
{
ky--;
rem[v] = 0;
for(auto j:c[v])
{
km[j]--;
if(km[j] == 0)
{
int nyk = -1;
int fe = -1;
for(int u = yk[j];u >= 0;--u)
{
if(rem[x[j][u].second] == 0)
{
continue;
}
if(fe == -1 || x[j][u].first == fe)
{
fe = x[j][u].first;
ck.erase({-int(c[x[j][u].second].size()),x[j][u].second});
c[x[j][u].second].push_back(j);
ck.insert({-int(c[x[j][u].second].size()),x[j][u].second});
km[j]++;
}
else
{
nyk = u;
break;
}
}
yk[j] = nyk;
}
}
c[v].clear();
}
else
break;
}
int64_t ans = 0;
for(int i = 0;i < 3;++i)
{
int64_t mx = 0;
for(int j = 0;j < n;++j)
{
mx = max(mx,rem[j] * xm[i][j]);
}
ans += mx;
}
cout << (ans == 0 || ky <= 2 ? -1 : ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
404 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
356 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
352 KB |
Output is correct |
22 |
Correct |
1 ms |
352 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
404 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
356 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
352 KB |
Output is correct |
22 |
Correct |
1 ms |
352 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
456 KB |
Output is correct |
26 |
Correct |
3 ms |
1116 KB |
Output is correct |
27 |
Correct |
3 ms |
1116 KB |
Output is correct |
28 |
Correct |
3 ms |
1256 KB |
Output is correct |
29 |
Correct |
5 ms |
1116 KB |
Output is correct |
30 |
Correct |
3 ms |
856 KB |
Output is correct |
31 |
Correct |
3 ms |
1116 KB |
Output is correct |
32 |
Correct |
5 ms |
1116 KB |
Output is correct |
33 |
Correct |
4 ms |
1116 KB |
Output is correct |
34 |
Correct |
4 ms |
1112 KB |
Output is correct |
35 |
Correct |
1 ms |
600 KB |
Output is correct |
36 |
Correct |
2 ms |
600 KB |
Output is correct |
37 |
Correct |
2 ms |
1116 KB |
Output is correct |
38 |
Correct |
4 ms |
1116 KB |
Output is correct |
39 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
440 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
91 ms |
28148 KB |
Output is correct |
12 |
Correct |
113 ms |
18476 KB |
Output is correct |
13 |
Correct |
73 ms |
21444 KB |
Output is correct |
14 |
Correct |
152 ms |
27820 KB |
Output is correct |
15 |
Correct |
106 ms |
32012 KB |
Output is correct |
16 |
Correct |
110 ms |
32924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
440 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
91 ms |
28148 KB |
Output is correct |
12 |
Correct |
113 ms |
18476 KB |
Output is correct |
13 |
Correct |
73 ms |
21444 KB |
Output is correct |
14 |
Correct |
152 ms |
27820 KB |
Output is correct |
15 |
Correct |
106 ms |
32012 KB |
Output is correct |
16 |
Correct |
110 ms |
32924 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
92 ms |
26824 KB |
Output is correct |
23 |
Correct |
130 ms |
25592 KB |
Output is correct |
24 |
Correct |
114 ms |
19284 KB |
Output is correct |
25 |
Correct |
214 ms |
26632 KB |
Output is correct |
26 |
Correct |
91 ms |
31852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
440 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
91 ms |
28148 KB |
Output is correct |
12 |
Correct |
113 ms |
18476 KB |
Output is correct |
13 |
Correct |
73 ms |
21444 KB |
Output is correct |
14 |
Correct |
152 ms |
27820 KB |
Output is correct |
15 |
Correct |
106 ms |
32012 KB |
Output is correct |
16 |
Correct |
110 ms |
32924 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
92 ms |
26824 KB |
Output is correct |
23 |
Correct |
130 ms |
25592 KB |
Output is correct |
24 |
Correct |
114 ms |
19284 KB |
Output is correct |
25 |
Correct |
214 ms |
26632 KB |
Output is correct |
26 |
Correct |
91 ms |
31852 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
456 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
5 ms |
1372 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
600 KB |
Output is correct |
34 |
Correct |
82 ms |
25492 KB |
Output is correct |
35 |
Correct |
129 ms |
24148 KB |
Output is correct |
36 |
Correct |
135 ms |
26660 KB |
Output is correct |
37 |
Correct |
198 ms |
26448 KB |
Output is correct |
38 |
Correct |
96 ms |
31832 KB |
Output is correct |
39 |
Correct |
89 ms |
18892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
440 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
91 ms |
28148 KB |
Output is correct |
12 |
Correct |
113 ms |
18476 KB |
Output is correct |
13 |
Correct |
73 ms |
21444 KB |
Output is correct |
14 |
Correct |
152 ms |
27820 KB |
Output is correct |
15 |
Correct |
106 ms |
32012 KB |
Output is correct |
16 |
Correct |
110 ms |
32924 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
92 ms |
26824 KB |
Output is correct |
23 |
Correct |
130 ms |
25592 KB |
Output is correct |
24 |
Correct |
114 ms |
19284 KB |
Output is correct |
25 |
Correct |
214 ms |
26632 KB |
Output is correct |
26 |
Correct |
91 ms |
31852 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Correct |
1 ms |
456 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
5 ms |
1372 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
600 KB |
Output is correct |
34 |
Correct |
82 ms |
25492 KB |
Output is correct |
35 |
Correct |
129 ms |
24148 KB |
Output is correct |
36 |
Correct |
135 ms |
26660 KB |
Output is correct |
37 |
Correct |
198 ms |
26448 KB |
Output is correct |
38 |
Correct |
96 ms |
31832 KB |
Output is correct |
39 |
Correct |
89 ms |
18892 KB |
Output is correct |
40 |
Correct |
3 ms |
860 KB |
Output is correct |
41 |
Correct |
3 ms |
1112 KB |
Output is correct |
42 |
Correct |
2 ms |
944 KB |
Output is correct |
43 |
Correct |
4 ms |
1116 KB |
Output is correct |
44 |
Correct |
90 ms |
27008 KB |
Output is correct |
45 |
Correct |
202 ms |
27148 KB |
Output is correct |
46 |
Correct |
180 ms |
27388 KB |
Output is correct |
47 |
Correct |
211 ms |
27176 KB |
Output is correct |
48 |
Correct |
110 ms |
32916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
404 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
356 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
352 KB |
Output is correct |
22 |
Correct |
1 ms |
352 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
456 KB |
Output is correct |
26 |
Correct |
3 ms |
1116 KB |
Output is correct |
27 |
Correct |
3 ms |
1116 KB |
Output is correct |
28 |
Correct |
3 ms |
1256 KB |
Output is correct |
29 |
Correct |
5 ms |
1116 KB |
Output is correct |
30 |
Correct |
3 ms |
856 KB |
Output is correct |
31 |
Correct |
3 ms |
1116 KB |
Output is correct |
32 |
Correct |
5 ms |
1116 KB |
Output is correct |
33 |
Correct |
4 ms |
1116 KB |
Output is correct |
34 |
Correct |
4 ms |
1112 KB |
Output is correct |
35 |
Correct |
1 ms |
600 KB |
Output is correct |
36 |
Correct |
2 ms |
600 KB |
Output is correct |
37 |
Correct |
2 ms |
1116 KB |
Output is correct |
38 |
Correct |
4 ms |
1116 KB |
Output is correct |
39 |
Correct |
1 ms |
600 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
460 KB |
Output is correct |
45 |
Correct |
1 ms |
344 KB |
Output is correct |
46 |
Correct |
1 ms |
440 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
91 ms |
28148 KB |
Output is correct |
51 |
Correct |
113 ms |
18476 KB |
Output is correct |
52 |
Correct |
73 ms |
21444 KB |
Output is correct |
53 |
Correct |
152 ms |
27820 KB |
Output is correct |
54 |
Correct |
106 ms |
32012 KB |
Output is correct |
55 |
Correct |
110 ms |
32924 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
1 ms |
348 KB |
Output is correct |
60 |
Correct |
1 ms |
604 KB |
Output is correct |
61 |
Correct |
92 ms |
26824 KB |
Output is correct |
62 |
Correct |
130 ms |
25592 KB |
Output is correct |
63 |
Correct |
114 ms |
19284 KB |
Output is correct |
64 |
Correct |
214 ms |
26632 KB |
Output is correct |
65 |
Correct |
91 ms |
31852 KB |
Output is correct |
66 |
Correct |
1 ms |
344 KB |
Output is correct |
67 |
Correct |
1 ms |
456 KB |
Output is correct |
68 |
Correct |
0 ms |
348 KB |
Output is correct |
69 |
Correct |
1 ms |
348 KB |
Output is correct |
70 |
Correct |
5 ms |
1372 KB |
Output is correct |
71 |
Correct |
1 ms |
468 KB |
Output is correct |
72 |
Correct |
1 ms |
600 KB |
Output is correct |
73 |
Correct |
82 ms |
25492 KB |
Output is correct |
74 |
Correct |
129 ms |
24148 KB |
Output is correct |
75 |
Correct |
135 ms |
26660 KB |
Output is correct |
76 |
Correct |
198 ms |
26448 KB |
Output is correct |
77 |
Correct |
96 ms |
31832 KB |
Output is correct |
78 |
Correct |
89 ms |
18892 KB |
Output is correct |
79 |
Correct |
3 ms |
860 KB |
Output is correct |
80 |
Correct |
3 ms |
1112 KB |
Output is correct |
81 |
Correct |
2 ms |
944 KB |
Output is correct |
82 |
Correct |
4 ms |
1116 KB |
Output is correct |
83 |
Correct |
90 ms |
27008 KB |
Output is correct |
84 |
Correct |
202 ms |
27148 KB |
Output is correct |
85 |
Correct |
180 ms |
27388 KB |
Output is correct |
86 |
Correct |
211 ms |
27176 KB |
Output is correct |
87 |
Correct |
110 ms |
32916 KB |
Output is correct |
88 |
Correct |
104 ms |
29184 KB |
Output is correct |
89 |
Correct |
193 ms |
29144 KB |
Output is correct |
90 |
Correct |
112 ms |
29100 KB |
Output is correct |
91 |
Correct |
244 ms |
28888 KB |
Output is correct |
92 |
Correct |
156 ms |
27624 KB |
Output is correct |
93 |
Correct |
205 ms |
27956 KB |
Output is correct |
94 |
Correct |
242 ms |
27944 KB |
Output is correct |
95 |
Correct |
104 ms |
34860 KB |
Output is correct |
96 |
Correct |
222 ms |
28968 KB |
Output is correct |
97 |
Correct |
105 ms |
36044 KB |
Output is correct |
98 |
Correct |
65 ms |
27476 KB |
Output is correct |
99 |
Correct |
192 ms |
27740 KB |
Output is correct |