Submission #91118

#TimeUsernameProblemLanguageResultExecution timeMemory
91118HideoBank (IZhO14_bank)C++14
52 / 100
1076 ms4568 KiB
#include <bits/stdc++.h> #define mk make_pair using namespace std; const int N = 25; int dp[N][1 << 16], a[N], b[N], sum[1 << 16]; int n, m; main(){ cin >> n >> m; for (int i = 1; i <= n; i++){ scanf ("%d", &a[i]); } for (int i = 1; i <= m; i++){ scanf ("%d", &b[i]); } for (int mask = 0; mask < (1 << m); mask++){ for (int i = 1; i <= m; i++){ if (mask & (1 << (i - 1))){ sum[mask] += b[i]; } } } dp[0][0] = 1; for (int i = 1; i <= n; i++){ for (int mask1 = 0; mask1 < (1 << m); mask1++){ for (int mask2 = mask1; mask2 > 0; mask2 = mask1 & (mask2 - 1)){ if (dp[i - 1][mask1 - mask2] == 1 && sum[mask2] == a[i]){ dp[i][mask1] = 1; break; } } } } for (int mask = 0; mask < (1 << m); mask++){ if (dp[n][mask]){ cout << "YES"; return 0; } } cout << "NO"; }

Compilation message (stderr)

bank.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
bank.cpp: In function 'int main()':
bank.cpp:14:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", &a[i]);
         ~~~~~~^~~~~~~~~~~~~
bank.cpp:17:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", &b[i]);
         ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...