# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
931876 |
2024-02-22T13:51:58 Z |
ace5 |
Team Contest (JOI22_team) |
C++17 |
|
116 ms |
28100 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
{
//if(j == 0)
// {
// cout << u << ' ' << x[j].size() << ' ';
// }
yk[j] = u;
break;
}
}
}
for(int j = 0;j < n;++j)
{
ck.insert({-int(c[j].size()),j});
}
while(ck.size())
{
int v = (*ck.begin()).second;
ck.erase(ck.begin());
if(c[v].size() >= 2)
{
rem[v] = 0;
for(auto j:c[v])
{
// cout << j << ' ' << km[j] << ' ' << yk[j] << "\n";
km[j]--;
if(km[j] == 0)
{
int nyk = -1;
for(int u = yk[j];u >= 0;--u)
{
if(x[j][u].first == x[j][yk[j]].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 ? -1 : ans);
return 0;
}
# |
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 |
1 ms |
348 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 |
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 |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
1 ms |
348 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 |
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 |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 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 |
116 ms |
28100 KB |
Output is correct |
12 |
Incorrect |
94 ms |
18484 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 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 |
116 ms |
28100 KB |
Output is correct |
12 |
Incorrect |
94 ms |
18484 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 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 |
116 ms |
28100 KB |
Output is correct |
12 |
Incorrect |
94 ms |
18484 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 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 |
116 ms |
28100 KB |
Output is correct |
12 |
Incorrect |
94 ms |
18484 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
1 ms |
348 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 |
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 |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |