답안 #777020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
777020 2023-07-08T13:52:48 Z aZvezda Team Contest (JOI22_team) C++14
0 / 100
1 ms 312 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const ll MAX_N = 1e5 + 10;
ll n;
pair<ll, ll> a[MAX_N], b[MAX_N], c[MAX_N];
pair<ll, pair<ll, ll> > p[MAX_N];

signed main() {
	cin >> n;
	for(ll i = 0; i < n; i ++) {
		cin >> p[i].first >> p[i].second.first >> p[i].second.second;
		a[i] = {p[i].first, i};
		b[i] = {p[i].second.first, i};
		c[i] = {p[i].second.second, i};
	}

	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);

	ll pa = n - 1, pb = n - 1, pc = n - 1;

	ll ans = -1;
	set<ll> st;

	while(true) {
		if(min({pa, pb, pc}) == -1) { break; }

		if(st.find(a[pa].second) != st.end()) { pa --; continue; }	
		if(st.find(b[pb].second) != st.end()) { pb --; continue; }	
		if(st.find(c[pc].second) != st.end()) { pc --; continue; }	

		if(a[pa].second == b[pb].second || a[pa].second == c[pc].second) { st.insert(a[pa].second); pa --; continue; }
		if(b[pb].second == c[pc].second) { st.insert(b[pb].second); pb --; continue; }
		
		if(p[a[pa].second].second.first > b[pb].first) {
			st.insert(a[pa].second);
			pa --;
			continue;
		}
		if(p[a[pa].second].second.second > c[pc].first) {
			st.insert(a[pa].second);
			pa --;
			continue;
		}
		if(p[b[pb].second].first > a[pa].first) {
			st.insert(b[pb].second);
			pb --;
			continue;
		}
		if(p[b[pb].second].second.second > c[pc].first) {
			st.insert(b[pb].second);
			pb --;
			continue;
		}
		if(p[c[pc].second].first > a[pa].first) {
			st.insert(c[pc].second);
			pc --;
			continue;
		}
		if(p[c[pc].second].second.first > b[pb].first) {
			st.insert(c[pc].second);
			pc --;
			continue;
		}
		ans = max(ans, a[pa].first + b[pb].first + c[pc].first);
		break;
	}

	cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 0 ms 308 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 0 ms 308 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 0 ms 308 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 0 ms 308 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 Incorrect 0 ms 212 KB Output isn't correct
11 Halted 0 ms 0 KB -