提出 #13092364


ソースコード 拡げる

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, M, X;
int C[12], A[12][12];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> X;
	rep(i, 0, N) {
		cin >> C[i];
		rep(j, 0, M) cin >> A[i][j];
	}

	int ans = inf;
	rep(msk, 0, 1 << N) {
		int cst = 0;
		vector<int> rikai(M, 0);

		rep(i, 0, N) if (msk & (1 << i)) {
			cst += C[i];
			rep(j, 0, M) rikai[j] += A[i][j];
		}

		bool ok = true;
		rep(i, 0, M) if (rikai[i] < X) ok = false;
		if (ok) chmin(ans, cst);
	}

	if (ans == inf) ans = -1;
	cout << ans << endl;
}





提出情報

提出日時
問題 C - Skill Up
ユーザ hamayanhamayan
言語 C++ (GCC 9.2.1)
得点 300
コード長 1876 Byte
結果 AC
実行時間 7 ms
メモリ 3656 KiB

ジャッジ結果

セット名 sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 24
セット名 テストケース
sample sample01, sample02, sample03
All border01, border02, border03, border04, hand01, hand02, hand03, hand04, hand05, large01, large02, large03, large04, large05, large06, large07, large08, random01, random02, random03, random04, sample01, sample02, sample03
ケース名 結果 実行時間 メモリ
border01 AC 5 ms 3612 KiB
border02 AC 3 ms 3544 KiB
border03 AC 3 ms 3480 KiB
border04 AC 3 ms 3536 KiB
hand01 AC 2 ms 3544 KiB
hand02 AC 2 ms 3588 KiB
hand03 AC 3 ms 3620 KiB
hand04 AC 7 ms 3568 KiB
hand05 AC 3 ms 3544 KiB
large01 AC 3 ms 3612 KiB
large02 AC 3 ms 3572 KiB
large03 AC 3 ms 3544 KiB
large04 AC 2 ms 3620 KiB
large05 AC 4 ms 3544 KiB
large06 AC 3 ms 3656 KiB
large07 AC 3 ms 3532 KiB
large08 AC 3 ms 3492 KiB
random01 AC 3 ms 3616 KiB
random02 AC 3 ms 3472 KiB
random03 AC 3 ms 3532 KiB
random04 AC 2 ms 3516 KiB
sample01 AC 2 ms 3588 KiB
sample02 AC 2 ms 3612 KiB
sample03 AC 2 ms 3520 KiB