Submission #1190963

#TimeUsernameProblemLanguageResultExecution timeMemory
1190963akbarrBank (IZhO14_bank)C++17
0 / 100
37 ms35452 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define run ios_base::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
#define endl '\n'
const int inf = 1e18+7;
const int sz = 2e5+5;
void solve() {
    freopen("bank.in" , "r" , stdin);
    freopen("bank.out" , "w" , stdout);
    int n,m;
    cin >> n >> m;
    vector<int>a(n),b(m);
    for(int i = 0;i < n;i++)   cin >> a[i];
    for(int i = 0; i < m;i++)  cin >> b[i];
    bool ok = false;
    for(int bt = 0;bt < 1 << m;bt++){
        int cost = 0;
        for(int i = 0; i < m;i++){
            if(bt & (1 << i)){
                cost+=b[i];
            }
        }
        if(cost == a[0]){
            ok = true;
            break;
        }
    }
    if(ok){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}
 
signed main() {
    run;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
// 11111100000

Compilation message (stderr)

bank.cpp: In function 'void solve()':
bank.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("bank.in" , "r" , stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("bank.out" , "w" , stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...