提出 #65492742


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> C(N);
	for (auto&& e : C) cin >> e;
	vector<vector<int>> G(N);
	for (int i = 0; i < M; i++) {
		int k;
		cin >> k;
		while (k--) {
			int x;
			cin >> x;
			x--;
			G[x].push_back(i);
		}
	}

	ll ans = 1e18;
	for (int S = 0; S < (1 << (2 * N)); S++) {
		vector<int> cnt(M);
		ll cost = 0;
		for (int i = 0; i < 2 * N; i++) {
			if (S >> i & 1) {
				for (auto&& e : G[i / 2]) cnt[e]++;
				cost += C[i / 2];
			}
		}
		if (*min_element(cnt.begin(), cnt.end()) >= 2) {
			ans = min(ans, cost);
		}
	}

	cout << ans << endl;
}

提出情報

提出日時
問題 D - Goin' to the Zoo
ユーザ nouka28
言語 C++ 20 (gcc 12.2)
得点 400
コード長 685 Byte
結果 AC
実行時間 618 ms
メモリ 3668 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 35
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 2 ms 3432 KiB
hand_02.txt AC 1 ms 3656 KiB
hand_03.txt AC 1 ms 3476 KiB
random_01.txt AC 615 ms 3464 KiB
random_02.txt AC 618 ms 3532 KiB
random_03.txt AC 341 ms 3368 KiB
random_04.txt AC 401 ms 3456 KiB
random_05.txt AC 96 ms 3564 KiB
random_06.txt AC 25 ms 3524 KiB
random_07.txt AC 414 ms 3476 KiB
random_08.txt AC 2 ms 3668 KiB
random_09.txt AC 86 ms 3372 KiB
random_10.txt AC 1 ms 3476 KiB
random_11.txt AC 401 ms 3524 KiB
random_12.txt AC 1 ms 3488 KiB
random_13.txt AC 99 ms 3468 KiB
random_14.txt AC 1 ms 3524 KiB
random_15.txt AC 369 ms 3424 KiB
random_16.txt AC 1 ms 3484 KiB
random_17.txt AC 118 ms 3492 KiB
random_18.txt AC 1 ms 3428 KiB
random_19.txt AC 89 ms 3484 KiB
random_20.txt AC 140 ms 3512 KiB
random_21.txt AC 2 ms 3368 KiB
random_22.txt AC 99 ms 3476 KiB
random_23.txt AC 2 ms 3416 KiB
random_24.txt AC 23 ms 3476 KiB
random_25.txt AC 2 ms 3528 KiB
random_26.txt AC 97 ms 3480 KiB
random_27.txt AC 2 ms 3416 KiB
random_28.txt AC 6 ms 3476 KiB
random_29.txt AC 6 ms 3420 KiB
random_30.txt AC 23 ms 3668 KiB
sample_01.txt AC 1 ms 3564 KiB
sample_02.txt AC 2 ms 3512 KiB