답안 #567827

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567827 2022-05-24T08:54:33 Z maomao90 Team Contest (JOI22_team) C++17
0 / 100
30 ms 4524 KB
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define RREP(i, j, k) for (int i = j; i >= k; i--)

template <class T>
bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;

#ifndef DEBUG
#define cerr if(0) cerr
#endif

const int MAXN = 150005;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;

int n;
iii xyz[MAXN];
set<ii> st[2];
ii lft, rht;
int ans;

int main() {
#ifndef DEBUG
	ios::sync_with_stdio(0), cin.tie(0);
#endif
	cin >> n;
	REP (i, 0, n) {
		int x, y, z; cin >> x >> y >> z;
		xyz[i] = {x, y, z};
	}
	sort(xyz, xyz + n, [&] (iii l, iii r) {
			return get<1>(l) < get<1>(r);
			});
	ans = -1;
	int ptr = 0;
	int mx[2] = {-1, -1}, mz[2] = {-1, -1};
	REP (i, 0, n) {
		while (ptr < i && get<1>(xyz[ptr]) < get<1>(xyz[i])) {
			auto [x, y, z] = xyz[ptr++];
			{
				auto [ptr, yes] = st[0].insert({x, z});
				if (!yes) {
					continue;
				}
				while (next(ptr) != st[0].end() && next(ptr) -> SE < z) {
					bool bz = mxto(mz[0], z);
					bool bx = mxto(mx[0], next(ptr) -> FI);
					if (bx || bz) {
						assert(mz[0] == z && mx[0] == next(ptr) -> FI);
					}
					st[0].erase(next(ptr));
				}
				if (ptr != st[0].begin() && prev(ptr) -> SE > z) {
					bool bz = mxto(mz[0], prev(ptr) -> SE);
					bool bx = mxto(mx[0], x);
					if (bx || bz) {
						assert(mz[0] == prev(ptr) -> SE && mx[0] == x);
					}
					st[0].erase(ptr);
				}
			}
			{
				auto [ptr, yes] = st[1].insert({x, z});
				if (!yes) {
					continue;
				}
				while (ptr != st[1].begin() && prev(ptr) -> SE > z) {
					bool bz = mxto(mz[1], prev(ptr) -> SE);
					bool bx = mxto(mx[1], x);
					if (bx || bz) {
						assert(mz[1] == prev(ptr) -> SE && mx[1] == x);
					}
					st[1].erase(prev(ptr));
				}
				if (next(ptr) != st[1].end() && next(ptr) -> SE < z) {
					bool bz = mxto(mz[1], z);
					bool bx = mxto(mx[1], next(ptr) -> FI);
					if (bx || bz) {
						assert(mz[1] == z && mx[1] == next(ptr) -> FI);
					}
					st[1].erase(ptr);
				}
			}
		}
		REP (z, 0, 2) {
			int my = -INF;
			auto [cx, cy, cz] = xyz[i];
			if (mx[z] == -1) continue;
			if (cx < mx[z] && cz < mz[z]) {
				my = cy;
			}
			if (my != -INF) {
				mxto(ans, mx[z] + my + mz[z]);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 1 ms 212 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Runtime error 1 ms 468 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 1 ms 212 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Runtime error 1 ms 468 KB Execution killed with signal 6
15 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 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 Runtime error 30 ms 4524 KB Execution killed with signal 6
12 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 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 Runtime error 30 ms 4524 KB Execution killed with signal 6
12 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 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 Runtime error 30 ms 4524 KB Execution killed with signal 6
12 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 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 Runtime error 30 ms 4524 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 1 ms 212 KB Output is correct
12 Correct 0 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Runtime error 1 ms 468 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -