Submission #870807

#TimeUsernameProblemLanguageResultExecution timeMemory
870807NurislamBank (IZhO14_bank)C++14
71 / 100
1071 ms1500 KiB
#include <bits/stdc++.h> using namespace std;/* <<<<It's never too late for a new beginning in your life>>>> Today is hard tomorrow will worse but the day after tomorrow will be the sunshine.. HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............ Never give up */ //The most CHALISHKANCHIK #define ios ios_base::sync_with_stdio(false);cin.tie(NULL); #define endl '\n' #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define pb push_back #define rew(i, a, b) for(int i = a; i < b; i++) #define wer(i, a, b) for(int i = b - 1; i >= a; i--) #define int long long typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; int n, m, ans = 0; int a[21]; map<pair<vi,multiset<int>>, bool>mp; vi us(21); multiset<int> b; void ch(){ if(mp[{us,b}])return; mp[{us,b}]=true; int it = 0; for(int i:us){ if(i == 0)break; it++; } if(it == n){cout << "YES\n";exit(NULL);} multiset<int> st = b; for(int ms = 1; ms < (int)(1<<b.size()); ms++){ vi res; int cnt = 0, sum = 0; for(int i:b){ if((ms>>cnt) & 1){ sum+=i; res.pb(i); } cnt++; //~ cout << ((ms >> cnt)&1); if(sum > a[it])break; } //~ cout << endl; if(sum == a[it]){ for(int i:res)b.erase(b.find(i)); us[it] = 1; ch(); us[it] = 0; b = st; } } } void solve(){ cin >> n >> m; rew(i, 0, n)cin >> a[i]; rew(i, 0, m){int x;cin >> x;b.insert(x);} ch(); cout << "NO\n"; } main(){ ios int t = 1; //~ cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

bank.cpp: In function 'void ch()':
bank.cpp:37:35: warning: passing NULL to non-pointer argument 1 of 'void exit(int)' [-Wconversion-null]
   37 |  if(it == n){cout << "YES\n";exit(NULL);}
      |                                   ^~~~
In file included from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from bank.cpp:1:
/usr/include/stdlib.h:617:23: note:   declared here
  617 | extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
      |                   ~~~~^~~~~~~~
bank.cpp: At global scope:
bank.cpp:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   68 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...