Submission #944316

#TimeUsernameProblemLanguageResultExecution timeMemory
9443164QT0RBank (IZhO14_bank)C++17
19 / 100
74 ms8580 KiB
#include <bits/stdc++.h> using namespace std; int sal[22]; int sal_pref[22]; int val[22]; pair<int,int> maski[1<<20]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,m,v; cin >> n >> m; for (int i = 0; i<n; i++){ cin >> sal[i]; sal_pref[i]=sal_pref[i-1]+sal[i]; } for (int i = 0; i<m; i++)cin >> val[i]; const int zak=1<<m; for (int i = 1; i<zak; i++){ for (int j = 0; j<m; j++){ if (i&(1<<j)){ int bez=i^(1<<j); maski[i].second=maski[bez].second+val[j]; if (maski[i].second-sal_pref[maski[bez].first]==sal[maski[bez].first+1]){ maski[i].first=max(maski[i].first,maski[bez].first+1); } if (maski[i].first==n){ cout << "YES\n"; return 0; } } } } cout << "NO\n"; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:13:10: warning: unused variable 'v' [-Wunused-variable]
   13 |  int n,m,v;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...