Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl "\n"
- void files(){
- ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- ll n,m,x; cin>>n>>m>>x;
- vector<vector<ll>> a(n, vector<ll>(m+1));
- for(ll i=0; i<n; i++){
- for(ll j=0; j<=m; j++){
- cin>>a[i][j];
- }
- }
- ll ans = LONG_LONG_MAX;
- for(int i=0; i<(1<<n); i++){
- ll sum = 0;
- vector<ll> b(m);
- for(int j=0; j<n; j++){
- if(i&(1<<j)){
- sum += a[j][0];
- for(int k=1;k<=m;k++){
- b[k-1] += a[j][k];
- }
- }
- }
- sort(b.begin(), b.end());
- if(b[0]>=x){
- ans = min(ans, sum);
- }
- }
- if(ans == LONG_LONG_MAX){
- cout<<-1<<nl;
- }else cout<<ans<<nl;
- }
- int main(){
- files();
- int t = 1;
- // cin>>t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement