제출 #656385

#제출 시각아이디문제언어결과실행 시간메모리
656385iskhakkutbilim은행 (IZhO14_bank)C++14
46 / 100
64 ms8216 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define all(a) a.begin(), a.end() const int M = 1e9 + 7; const int N = 21; int dp[N][1<<N], a[N], b[N]; int n, m; vector<int> g[N]; main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0;i < n; i++){ cin >> a[i]; } for(int i = 0;i < m; i++){ cin >> b[i]; } for(int mask = 0; mask < (1<<m); mask++){ int sum = 0; for(int i = 0;i < m; i++){ if(mask & (1<<i)){ sum+= b[i]; } } for(int i = 0;i < n; i++){ if(a[i] == sum){ g[i].push_back(mask); } } } for(int i = 0;i < n; i++){ if(g[i].empty()){ cout << "NO"; return 0; } } for(auto x : g[0]){ dp[0][x] = 1; } for(int i = 1;i < n; i++){ for(int mask = 0; mask < (1<<m); mask++){ for(auto x : g[i]){ if((mask & x) == 0){ dp[i][mask|x] = 1; } } } } for(int mask = 1; mask < (1<<m); mask++){ if(dp[n-1][mask] == 1){ cout << "YES"; return 0; } } cout << "NO"; return 0; }

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

bank.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | 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...