Submission #1085780

#TimeUsernameProblemLanguageResultExecution timeMemory
1085780SunbaeBank (IZhO14_bank)C++17
71 / 100
1072 ms8624 KiB
#include <cstdio> #include <string> #include <algorithm> using namespace std; int dp[1<<20], s[1<<20]; int a[20], b[20]; int M[20][1<<20], sz[20]; signed main(){ int n, m; scanf("%d %d", &n, &m); for(int i = 0; i<n; ++i) scanf("%d", a+i); for(int i = 0; i<m; ++i) scanf("%d", b+i); int lim = 1<<m; for(int mk = 0; mk<lim; ++mk){ for(int j = 0; j<m; ++j) s[mk] += (mk>>j&1) * b[j]; dp[mk] |= (s[mk] == a[0]); for(int i = 1; i<n; ++i) if(s[mk] == a[i]) M[i][sz[i]++] = mk; } for(int i = 1; i<n; ++i){ for(int mk = lim-1; mk>=0; --mk){ dp[mk] = 0; for(int j = 0; j<sz[i]; ++j){ int k = M[i][j]; if((mk & k) == k) dp[mk] |= dp[mk ^ k]; } } } (*max_element(dp, dp+lim)) ? puts("YES") : puts("NO"); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  int n, m; scanf("%d %d", &n, &m);
      |            ~~~~~^~~~~~~~~~~~~~~~~
bank.cpp:10:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  for(int i = 0; i<n; ++i) scanf("%d", a+i);
      |                           ~~~~~^~~~~~~~~~~
bank.cpp:11:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  for(int i = 0; i<m; ++i) 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...