Submission #1085797

#TimeUsernameProblemLanguageResultExecution timeMemory
1085797SunbaeBank (IZhO14_bank)C++17
100 / 100
87 ms8612 KiB
#include <bits/stdc++.h> const int inf = 2e8; using namespace std; int a[20], b[20], dp[1<<20], l[1<<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; memset(dp, -1, sizeof(dp)); dp[0] = 0; for(int mk = 0; mk<lim; ++mk){ for(int i = 0; i<m; ++i){ if(mk>>i&1){ int pmk = mk ^ (1<<i); if(dp[pmk] != -1 && b[i] + l[pmk] == a[dp[pmk]]){ dp[mk] = max(dp[mk], dp[pmk] + 1); l[mk] = 0; }else if(dp[pmk] != -1 && b[i] + l[pmk] < a[dp[pmk]]){ dp[mk] = max(dp[mk], dp[pmk]); l[mk] = b[i] + l[pmk]; } } } } (*max_element(dp, dp+lim) == n) ? puts("YES") : puts("NO"); }

Compilation message (stderr)

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