Submission #717383

#TimeUsernameProblemLanguageResultExecution timeMemory
717383tigarBank (IZhO14_bank)C++14
25 / 100
1080 ms300 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, int k) { //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]; //cout<<i<<" "<<given[covek]<<" "<<people[covek]<<" "<<pay[i]<<endl; if(given[covek]<people[covek])ret=(ret|rekurzivna(covek, k+1)); else if(given[covek]==people[covek])ret=(ret|rekurzivna(covek+1, k+1)); given[covek]-=pay[i]; used[i]=false; } if(ret)break; } //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, 0))cout<<"YES\n"; else cout<<"NO\n"; return 0; } /*1 8 9 1 1 1 1 1 1 1 1*/

Compilation message (stderr)

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