Submission #90687

#TimeUsernameProblemLanguageResultExecution timeMemory
90687popovicirobertBank (IZhO14_bank)C++14
100 / 100
614 ms764 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define ld long double // 217 // 44 using namespace std; vector <short> a, b; short n, m; void bkt1(short , vector <short> &); int cnt = 0; void bkt2(short pa, short pb, vector <short> &b, short sum, vector <short> &aux) { if(cnt > 40000000) { cout << "NO"; exit(0); } if(pb == b.size()) { if(sum == a[pa]) { bkt1(pa + 1, aux); } } else { cnt++; bkt2(pa, pb + 1, b, sum + b[pb], aux); aux.push_back(b[pb]); cnt++; bkt2(pa, pb + 1, b, sum, aux); aux.pop_back(); } } void bkt1(short pa, vector <short> &b) { if(pa == n) { cout << "YES"; exit(0); } else { vector <short> aux; bkt2(pa, 0, b, 0, aux); } } int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); short i; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m; a.resize(n); b.resize(m); for(i = 0; i < n; i++) { cin >> a[i]; } for(i = 0; i < m; i++) { cin >> b[i]; } sort(b.begin(), b.end(), greater<int>()); sort(a.begin(), a.end(), greater<int>()); bkt1(0, b); cout << "NO"; //cin.close(); //cout.close(); return 0; }

Compilation message (stderr)

bank.cpp: In function 'void bkt2(short int, short int, std::vector<short int>&, short int, std::vector<short int>&)':
bank.cpp:22:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(pb == b.size()) {
        ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...