제출 #1123911

#제출 시각아이디문제언어결과실행 시간메모리
1123911aram_7은행 (IZhO14_bank)C++20
0 / 100
282 ms327680 KiB
#include <bits/stdc++.h> using namespace std; using ll=long long; int ok=1; vector<vector<int>>gp; void stugum(int num){ for(auto &x:gp[num]){ if(x^num){ ok=0; } stugum(x); } } void solve(){ int n,m; cin>>n>>m; vector<int>a(n),b(m); for(int i=0;i<n;i++){ cin>>a[i]; } int sum=0; for(int i=0;i<m;i++){ cin>>b[i]; sum+=b[i]; } gp=vector<vector<int>>((1<<m)); for(int i=0;i<(1<<n);i++){ int ans=0; for(int j=0;j<m;j++){ if(i & (1<<j)){ ans+=b[j]; } } gp[ans].push_back(i); } for(int i=0;i<n;i++){ stugum(a[i]); } if(ok){ cout<<"YES"<<endl; return; } cout<<"NO"<<endl; } int main(){ int t=1; //cin>>t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...