Submission #839168

#TimeUsernameProblemLanguageResultExecution timeMemory
839168DeathIsAweBank (IZhO14_bank)C++17
100 / 100
91 ms8544 KiB
#include <bits/stdc++.h> using namespace std; int dp[10000000],rem[10000000]; int main() { int n,m; cin >> n >> m; vector<int> people(n),notes(m); for (int i=0;i<n;i++) { cin >> people[i]; } for (int i=0;i<m;i++) { cin >> notes[i]; } int miss,maxdp,temp,temp2; dp[0]=0; rem[0]=0; for (int i=1;i<(int)pow(2,m);i++) { temp2=1; maxdp=-1; for (int j=0;j<m;j++) { if ((i^temp2)<i && maxdp<dp[(i^temp2)]) { temp=(i^temp2); maxdp=dp[(i^temp2)]; miss=j; } temp2*=2; } if (rem[temp]+notes[miss]==people[maxdp]) { dp[i]=maxdp+1; rem[i]=0; } else { dp[i]=maxdp; rem[i]=rem[temp]+notes[miss]; } if (dp[i]==n) { cout << "YES"; return 0; } } cout << "NO"; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:27:21: warning: 'temp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |         if (rem[temp]+notes[miss]==people[maxdp]) {
      |             ~~~~~~~~^
bank.cpp:27:33: warning: 'miss' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |         if (rem[temp]+notes[miss]==people[maxdp]) {
      |                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...