Submission #13092364
Source Code Expand
Copy
#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;
}
Submission Info
Submission Time |
|
Task |
C - Skill Up |
User |
hamayanhamayan |
Language |
C++ (GCC 9.2.1) |
Score |
300 |
Code Size |
1876 Byte |
Status |
AC |
Exec Time |
7 ms |
Memory |
3656 KB |
Judge Result
Set Name |
sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
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 |
Case Name |
Status |
Exec Time |
Memory |
border01 |
AC |
5 ms |
3612 KB |
border02 |
AC |
3 ms |
3544 KB |
border03 |
AC |
3 ms |
3480 KB |
border04 |
AC |
3 ms |
3536 KB |
hand01 |
AC |
2 ms |
3544 KB |
hand02 |
AC |
2 ms |
3588 KB |
hand03 |
AC |
3 ms |
3620 KB |
hand04 |
AC |
7 ms |
3568 KB |
hand05 |
AC |
3 ms |
3544 KB |
large01 |
AC |
3 ms |
3612 KB |
large02 |
AC |
3 ms |
3572 KB |
large03 |
AC |
3 ms |
3544 KB |
large04 |
AC |
2 ms |
3620 KB |
large05 |
AC |
4 ms |
3544 KB |
large06 |
AC |
3 ms |
3656 KB |
large07 |
AC |
3 ms |
3532 KB |
large08 |
AC |
3 ms |
3492 KB |
random01 |
AC |
3 ms |
3616 KB |
random02 |
AC |
3 ms |
3472 KB |
random03 |
AC |
3 ms |
3532 KB |
random04 |
AC |
2 ms |
3516 KB |
sample01 |
AC |
2 ms |
3588 KB |
sample02 |
AC |
2 ms |
3612 KB |
sample03 |
AC |
2 ms |
3520 KB |