Submission #717376

#TimeUsernameProblemLanguageResultExecution timeMemory
717376tigarBank (IZhO14_bank)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int people[30], pay[30]; bool used[30]; int given[30]; int n, m; bool rekurzivna(int covek) { //cout<<"-->"<<k<<endl; if(covek==n)return true; bool ret=false; for(int i=0; i<m; i++) { if(!used[i]) { //cout<<i<<endl; used[i]=true; given[covek]+=pay[i]; if(given[covek]+pay[i]<people[covek])ret=(ret|rekurzivna(covek)); else if(given[covek]+pay[i]==people[covek])ret=(ret|rekurzivna(covek+1)); given[covek]-=pay[i]; used[i]=false; } } //cout<<"-->"<<k<<endl; return ret; } int main() { #define name "bank" if(fopen(name".inp", "r")){ freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } ios_base::sync_with_stdio(); cin.tie(); cout.tie(); cin>>n>>m; for(int i=0; i<n; i++)cin>>people[i]; for(int j=0; j<m; j++)cin>>pay[j]; if(rekurzivna(0))cout<<"YES"; else cout<<"NO"; return 0; } /*1 15 9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15*/

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(name".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...