結果

問題 No.2182 KODOKU Stone
ユーザー MasKoaTS
提出日時 2022-09-10 18:55:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 995 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 203,008 KB
最終ジャッジ日時 2025-02-07 04:08:58
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 TLE * 29
権限があれば一括ダウンロードができます

ソースコード

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