Submission #777018

# Submission time Handle Problem Language Result Execution time Memory
777018 2023-07-08T13:52:08 Z aZvezda Team Contest (JOI22_team) C++14
0 / 100
6 ms 564 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(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(min({pa, pb, pc}) == -1) { break; }
		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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 6 ms 564 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -