結果

問題 No.2182 KODOKU Stone
ユーザー MasKoaTSMasKoaTS
提出日時 2022-11-29 12:20:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,318 bytes
コンパイル時間 2,891 ms
コンパイル使用メモリ 214,340 KB
実行使用メモリ 10,500 KB
最終ジャッジ日時 2024-04-26 21:07:05
合計ジャッジ時間 6,631 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 126 ms
10,500 KB
testcase_12 AC 156 ms
10,240 KB
testcase_13 AC 40 ms
5,376 KB
testcase_14 AC 39 ms
5,376 KB
testcase_15 AC 167 ms
10,376 KB
testcase_16 AC 141 ms
10,248 KB
testcase_17 AC 50 ms
5,376 KB
testcase_18 AC 118 ms
9,212 KB
testcase_19 AC 81 ms
6,404 KB
testcase_20 AC 104 ms
7,992 KB
testcase_21 AC 45 ms
5,376 KB
testcase_22 AC 39 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 56 ms
5,376 KB
testcase_25 AC 31 ms
5,376 KB
testcase_26 AC 30 ms
5,376 KB
testcase_27 AC 31 ms
5,376 KB
testcase_28 AC 91 ms
7,652 KB
testcase_29 AC 118 ms
8,632 KB
testcase_30 AC 130 ms
9,416 KB
testcase_31 AC 97 ms
7,344 KB
testcase_32 AC 95 ms
7,324 KB
testcase_33 AC 108 ms
8,248 KB
testcase_34 AC 59 ms
5,376 KB
testcase_35 AC 115 ms
8,240 KB
testcase_36 AC 27 ms
5,376 KB
testcase_37 AC 126 ms
9,264 KB
testcase_38 WA -
testcase_39 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define all(x) x.begin(), x.end()
#define last(x) x[x.size() - 1]
using namespace std;
template <class T>	using V = vector<T>;

bool check(int& N, V<int>&K, V<V<int> >&A, int m) {
	deque<int> P = {};	deque<int> Q = {};
	rep(i, 0, N) {
		int s = 0;
		for (int a : A[i]) {
			s += (a >= m);
		}
		if (s < A[i].size()) {
			P.push_back(s);
		}
		else {
			Q.push_back(s);
		}
	}
	sort(all(P));	sort(all(Q));

	rep(i, 1, N + 1) {
		int k = K[N - i];
		int p = P.empty() ? -1 : last(P);
		int q = Q.empty() ? -1 : last(Q);

		if (max(p, q) >= k) {
			return true;
		}
		else if (i < N and p == k - 1) {
			P.pop_back();
		}
		else if (q != -1) {
			Q.pop_front();
		}
		else {
			return false;
		}
	}
	return true;
}


int main(void) {
	int N;	cin >> N;
	V<int> K(N);
	rep(i, 0, N) {
		cin >> K[i];
	}
	V<int> T(N);
	V<V<int> > A(N, V<int>({}));
	V<int> st = {};
	rep(i, 0, N) {
		cin >> T[i];
		rep(j, 0, T[i]) {
			int a;	cin >> a;
			A[i].push_back(a);
			st.push_back(a);
		}
	}
	st.erase(unique(all(st)), st.end());
	sort(all(st));

	int ok = 0, ng = st.size();
	while (ng - ok > 1) {
		int t = (ok + ng) >> 1;
		if (check(N, K, A, st[t])) {
			ok = t;
		}
		else {
			ng = t;
		}
	}

	int ans = st[ok];
	cout << ans << endl;

	return 0;
}
0