제출 #421222

#제출 시각아이디문제언어결과실행 시간메모리
421222antimirage은행 (IZhO14_bank)C++14
100 / 100
155 ms4488 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back using namespace std; int n, m, dp[(1 << 20) + 5], a[25], b[25]; int main (){ cin >> n >> m; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); a[i] += a[i - 1]; } for (int i = 0; i < m; i++) { scanf("%d", &b[i]); } memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int mask = 0; mask < (1 << m); mask++) { if (dp[mask] == -1) continue; if (dp[mask] == n) { puts("YES"); return 0; } int sum = 0; for (int j = 0; j < m; j++) { if (mask & (1 << j)) sum += b[j]; } for (int j = 0; j < m; j++) { if (mask & (1 << j)) continue; if (sum + b[j] < a[dp[mask] + 1]) { dp[mask | (1 << j)] = dp[mask]; } else if (sum + b[j] == a[dp[mask] + 1]) { dp[mask | (1 << j)] = dp[mask] + 1; } } } puts("NO"); }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
bank.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         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...