Submission #550766

#TimeUsernameProblemLanguageResultExecution timeMemory
550766AJ00Bank (IZhO14_bank)C++14
19 / 100
61 ms212 KiB
#include <bits/stdc++.h> using namespace std; int from[20],achieve[20]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tc=1,n,q,k,m; //cin >> tc; for (int poppo = 1; poppo <= tc; poppo++){ cin >> n >> m; for (int i = 0; i < n; i++){ cin >> achieve[i]; } sort(achieve,achieve+n); for (int i = 0; i < m; i++){ cin >> from[i]; } sort(from,from+m); bool pos = false; for (int mask = 0; mask < (1<<m); mask++){ int cursum = 0,curitr=0; for (int i = 0; i < m; i++){ if ((1<<i)&mask){ cursum += from[i]; if (cursum == achieve[curitr]){ curitr++; cursum = 0; } } } if (curitr == n){ pos = true; break; } } pos ? cout << "YES\n" : cout << "NO\n"; } return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:9:16: warning: unused variable 'q' [-Wunused-variable]
    9 |     int tc=1,n,q,k,m;
      |                ^
bank.cpp:9:18: warning: unused variable 'k' [-Wunused-variable]
    9 |     int tc=1,n,q,k,m;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...