Submission #604959

# Submission time Handle Problem Language Result Execution time Memory
604959 2022-07-25T11:12:19 Z MohamedAhmed04 Team Contest (JOI22_team) C++14
0 / 100
85 ms 9052 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 2e5 + 10 ;

int arr[MAX][3] ;
int n ;

vector< array<int , 3> >v[3] ;

long long solve(int t1 , int t2 , int t3)
{
	long long Max = -1 ;
	int j = n-1 , k = n-1 ;
	for(int i = n-1 ; i >= 0 ; --i)
	{
		while(j >= 0 && v[t2][j][t1] >= v[t1][i][t1])
			--j ;
		if(j == -1)
			break ;
		while(k >= 0 && (v[t3][k][t1] >= v[t1][i][t1] || v[t3][k][t2] >= v[t2][j][t2]))
			--k ;
		if(k == -1)
			break ;
		if(v[t1][i][t2] >= v[t2][j][t2] || v[t1][i][t3] >= v[t3][k][t3] || v[t2][j][t3] >= v[t3][k][t3])
			continue ;
		Max = max(Max , 1ll * v[t1][i][t1] + v[t2][j][t2] + v[t3][k][t3]) ;
	}
	return Max ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2] ;
		v[0].push_back({arr[i][0] , -1 * arr[i][1] , -1 * arr[i][2]}) ;
		v[1].push_back({arr[i][1] , -1 * arr[i][0] , -1 * arr[i][2]}) ;
		v[2].push_back({arr[i][2] , -1 * arr[i][1] , -1 * arr[i][0]}) ;
	}
	sort(v[0].begin() , v[0].end()) ;
	sort(v[1].begin() , v[1].end()) ;
	sort(v[2].begin() , v[2].end()) ;
	for(int i = 0 ; i < n ; ++i)
	{
		v[0][i][1] *= -1 , v[0][i][2] *= -1 ;
		v[1][i][1] *= -1 , v[1][i][2] *= -1 ;
		v[2][i][1] *= -1 , v[2][i][2] *= -1 ;
		swap(v[1][i][0] , v[1][i][1]) , swap(v[2][i][0] , v[2][i][2]) ;
	}
	vector<int>order = {0 , 1 , 2} ;
	long long ans = -1 ;
	do
	{
		ans = max(ans , solve(order[0] , order[1] , order[2])) ;
	}while(next_permutation(order.begin() , order.end())) ;
	return cout<<ans<<"\n" , 0 ;
}
# 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Incorrect 1 ms 328 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Incorrect 1 ms 328 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 85 ms 9052 KB Output is correct
12 Incorrect 52 ms 5696 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 85 ms 9052 KB Output is correct
12 Incorrect 52 ms 5696 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 85 ms 9052 KB Output is correct
12 Incorrect 52 ms 5696 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 85 ms 9052 KB Output is correct
12 Incorrect 52 ms 5696 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 328 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Incorrect 1 ms 328 KB Output isn't correct
16 Halted 0 ms 0 KB -