Submission #620023

# Submission time Handle Problem Language Result Execution time Memory
620023 2022-08-02T18:56:28 Z CSQ31 Team Contest (JOI22_team) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
typedef pair<int,int> pii;
typedef long long int ll;
const int MAXN = 5e5;
int a[MAXN],b[MAXN],c[MAXN];
bool del[MAXN];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	vector<int>pa(n),pb(n),pc(n);
	for(int i=0;i<n;i++){
		pa[i] = pb[i] = pc[i] = i;
	}
	sort(all(pa),[&](int i,int j){return a[j] > a[i];});
	sort(all(pb),[&](int i,int j){return b[j] > b[i];});
	sort(all(pc),[&](int i,int j){return c[j] > c[i];});
	int ta,tb,tc;
	ta = tb = tc = n-1;
	while(ta>=0 && tb>=0 && tc>=0){
		int cnta = 0,cntb = 0,cntc = 0;
		if(b[pa[ta]] == b[pb[tb]])cnta++;
		if(c[pa[ta]] == c[pc[tc]])cnta++;
		
		if(a[pb[tb]] == a[pa[ta]])cntb++;
		if(c[pb[tb]] == c[pc[tc]])cntb++;
		
		if(a[pc[tc]] == a[pa[ta]])cntc++;
		if(b[pc[tc]] == b[pb[tb]])cntc++;
		//cout<<cnta<<'\n';
		if(cnta==2){
			del[pa[ta]] = 1;
			ta--;
		}
		else if(cntb==2){
			del[pb[tb]] = 1;
			tb--;
		}
		else if(cntc==2){
			del[pc[tc]] = 1;
			tc--;
		}
		else{
			cout<<a[pa[ta]] + b[pb[tb]] + c[pc[tc]]<<'\n';
			return 0;
		}
		while(ta != -1 && del[pa[ta]])ta--;
		while(tb != -1 && del[pb[tb]])tb--;
		while(tc != -1 && del[pc[tc]])tc--;
		
		
	}
	cout<<-1;
	
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -