제출 #734501

#제출 시각아이디문제언어결과실행 시간메모리
734501keta_tsimakuridze은행 (IZhO14_bank)C++14
100 / 100
139 ms8560 KiB
#include<bits/stdc++.h> #define f first #define s second #define int long long #define pii pair<int,int> using namespace std; const int N = 20 , mod = 1e9 + 7; // ! int t, a[N], b[N]; int dp[(1 << N)]; main(){ int n, m; cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i], a[i] += a[i - 1]; for(int i = 0; i < m; i++) cin >> b[i]; for(int i = 0; i < (1 << m); i++) { int cur = 0; for(int j = 0; j < m; j++) if((1 << j) & i) cur += b[j]; for(int j = 0; j < m; j++) { if((1 << j) & i) { dp[i] = max(dp[i], dp[i ^ (1 << j)] + (a[dp[i ^ (1 << j)]] == cur)); } } // cout << i << " __ " << a[dp[i] + 1] << endl; } cout << (dp[(1 << m) - 1] == n ? "YES" : "NO"); }

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

bank.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...