# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
918280 |
2024-01-29T14:23:59 Z |
_VIBE |
Team Contest (JOI22_team) |
C++17 |
|
2000 ms |
38736 KB |
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>ordered_multiset;
#define int long long
#define endl '\n'
void Excuse_Me(int TC)
{
int n;
cin>>n;
vector<int> mx(3,0);
priority_queue<pair<int,pair<int,int>>> pq;
set<pair<int,int>> s[3];
vector<vector<int>> g(n,vector<int>(3));
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
int x;
cin>>x;
pq.push({x,{j,i}});
mx[j]=max(mx[j],x);
g[i][j]=x;
}
}
while(!pq.empty()){
pair<int,pair<int,int>> p=pq.top();
pq.pop();
int i=p.second.second,j=p.second.first;
bool poss=true;
for(int k=0;k<3;k++){
if(k==j) continue;
if(g[i][k]==mx[k]) poss=false;
}
if(poss) s[j].insert({p.first,i});
}
int ans=-1;
for(auto it1=s[0].begin();it1!=s[0].end();it1++){
for(auto it2=s[1].begin();it2!=s[1].end();it2++){
for(auto it3=s[2].begin();it3!=s[2].end();it3++){
int i=(*it1).second,j=(*it2).second,k=(*it3).second;
if(i==j or i==k or j==k) continue;
if(g[j][0]>=g[i][0] or g[k][0]>=g[i][0]) continue;
if(g[i][1]>=g[j][1] or g[k][1]>=g[j][1]) continue;
if(g[i][2]>=g[k][2] or g[j][2]>=g[k][2]) continue;
ans=max(ans,g[i][0]+g[j][1]+g[k][2]);
}
}
}
cout<<ans;
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
freopen("error.txt","w",stderr);
int Tc=1;
// cin>>Tc;
for(int tc=1;tc<=Tc;tc++)
{
Excuse_Me(tc);
}
return 0;
}
Compilation message
team.cpp: In function 'int main()':
team.cpp:77:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
77 | freopen("error.txt","w",stderr);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
140 ms |
348 KB |
Output is correct |
15 |
Correct |
64 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
348 KB |
Output is correct |
17 |
Correct |
128 ms |
344 KB |
Output is correct |
18 |
Correct |
112 ms |
344 KB |
Output is correct |
19 |
Correct |
132 ms |
536 KB |
Output is correct |
20 |
Correct |
79 ms |
548 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
117 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
128 ms |
348 KB |
Output is correct |
25 |
Correct |
125 ms |
536 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 |
0 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 |
1 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
140 ms |
348 KB |
Output is correct |
15 |
Correct |
64 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
348 KB |
Output is correct |
17 |
Correct |
128 ms |
344 KB |
Output is correct |
18 |
Correct |
112 ms |
344 KB |
Output is correct |
19 |
Correct |
132 ms |
536 KB |
Output is correct |
20 |
Correct |
79 ms |
548 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
117 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
128 ms |
348 KB |
Output is correct |
25 |
Correct |
125 ms |
536 KB |
Output is correct |
26 |
Execution timed out |
2017 ms |
1620 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2084 ms |
38736 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2084 ms |
38736 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2084 ms |
38736 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
2084 ms |
38736 KB |
Time limit exceeded |
12 |
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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
140 ms |
348 KB |
Output is correct |
15 |
Correct |
64 ms |
348 KB |
Output is correct |
16 |
Correct |
96 ms |
348 KB |
Output is correct |
17 |
Correct |
128 ms |
344 KB |
Output is correct |
18 |
Correct |
112 ms |
344 KB |
Output is correct |
19 |
Correct |
132 ms |
536 KB |
Output is correct |
20 |
Correct |
79 ms |
548 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
117 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
128 ms |
348 KB |
Output is correct |
25 |
Correct |
125 ms |
536 KB |
Output is correct |
26 |
Execution timed out |
2017 ms |
1620 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |