結果

問題 No.2182 KODOKU Stone
ユーザー MasKoaTSMasKoaTS
提出日時 2022-09-10 18:55:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 995 bytes
コンパイル時間 2,630 ms
コンパイル使用メモリ 203,980 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-26 21:04:17
合計ジャッジ時間 7,434 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 900 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//愚直解

#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define itrep(itr, st) for(auto itr = st.begin(); itr != st.end(); itr++)
#define all(x) x.begin(), x.end()
using namespace std;
template <class T>	using V = vector<T>;


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>({}));
	rep(i, 0, N) {
		cin >> T[i];
		rep(j, 0, T[i]) {
			int a;	cin >> a;
			A[i].push_back(a);
		}
	}
	
	V<int> perm(N);
	rep(i, 0, N) {
		perm[i] = i;
	}

	int ans = 0;
	do {
		int last = 1;
		rep(i, 0, N) {
			multiset<int> st = {};
			if (last != 1) {
				st.insert(last);
			}
			last = 1;
			for (int a : A[perm[i]]) {
				st.insert(-a);
			}
			int k = 0, bk = 0;
			itrep(itr, st) {
				k++;
				bk = *itr;
				if (k == K[i]) {
					last = bk;
				}
			}
			if (last == 1) {
				last = bk;
			}
		}
		ans = max(ans, -last);
	} while (next_permutation(all(perm)));

	cout << ans << endl;

	return 0;
}
0