제출 #1106116

#제출 시각아이디문제언어결과실행 시간메모리
1106116akzytr은행 (IZhO14_bank)C++17
19 / 100
1044 ms1096 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define arr array #define vec vector #define sz(a) ((int)(a).size()) void B() { /* Problem B: Bank Subtask 1: n = 1, Normal knapsack, 1000 Subtask 2: M <= 10 */ int N, M; cin >> N >> M; int a[N]; int b[M]; int g[M]; for(int i = 0; i < N; i++) { scanf("%d", &a[i]); } for(int i = 0; i < M; i++) { scanf("%d", &b[i]); g[i] = i; } if(N == 1) { bitset<(int)1e4> dp; dp[0] = 1; for(int i : b) { dp |= (dp << i); } cout << (dp[a[0]] ? "YES" : "NO"); return; } if(N > M) { cout << "NO" << endl; return; } // sort(b, b + M); assert(M <= 10); bool ok = 0; do { int x = 0; ll s = 0; for(int i = 0; i < M; i++) { if(s + b[g[i]] > a[x]) { break; } s += b[g[i]]; if(s + b[g[i]] == a[x]) { x++; s = 0; } if(x == N) { ok = 1; break; } } cout << endl; } while(next_permutation(g, g + M)); cout << (ok ? "YES" : "NO") << endl; } int main() { B(); }

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

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