답안 #696142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
696142 2023-02-05T15:58:08 Z hpesoj Team Contest (JOI22_team) C++17
0 / 100
1 ms 472 KB
#include <bits/stdc++.h>
#define int long long
#define pi pair <int, int>
#define ppi pair <pi, int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;

int n, t, c, f, g, h;
vector <pi> x, y, z;
bool removed[150005];
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
/*int randnums[200005];
void gen(){
	for(int i = 0; i < 200005; i++){
		randnums[i] = rng() / 200005 + 1;
		//cout << randnums[i] << '\n';
	}
}*/

signed main(){
	ios::sync_with_stdio(0), cin.tie(0);
	memset(removed, 0, sizeof(removed));
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> f >> g >> h;
		x.pb({f, i}), y.pb({g, i}), z.pb({h, i});
	}
	sort(all(x)), sort(all(y)), sort(all(z));
	while(1){
		while(!x.empty() and removed[x.back().se]) x.pop_back();
		while(!y.empty() and removed[y.back().se]) y.pop_back();
		while(!z.empty() and removed[z.back().se]) z.pop_back();
		if(x.empty() or y.empty() or z.empty()){
			cout << -1;
			break;
		}
		int i = -1, j = -1, k = -1;
		if(!x.empty()){
			i = x.back().se;
			//cout << x.back().fi << ' ' << i << ' ';
		}
		if(!y.empty()){
			j = y.back().se;
			//cout << y.back().fi << ' ' << j << ' ';
		}
		if(!z.empty()){
			k = z.back().se;
			//cout << z.back().fi << ' ' << k << ' ';
		}
		//cout << '\n';
		if(i == j and j == k and i != -1) x.pop_back(), y.pop_back(), z.pop_back(), removed[i] = 1;
		else if(i == j and i != -1) x.pop_back(), y.pop_back(), removed[i] = 1;
		else if(i == k and i != -1) x.pop_back(), z.pop_back(), removed[i] = 1;
		else if(j == k and j != -1) y.pop_back(), z.pop_back(), removed[j] = 1;
		else{
			cout << x.back().fi + y.back().fi + z.back().fi;
			break;
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Incorrect 1 ms 468 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Incorrect 1 ms 468 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 472 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 472 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 472 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 472 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Incorrect 1 ms 468 KB Output isn't correct
11 Halted 0 ms 0 KB -