제출 #1001387

#제출 시각아이디문제언어결과실행 시간메모리
1001387cnn008은행 (IZhO14_bank)C++17
52 / 100
1037 ms23132 KiB
#include "bits/stdc++.h" using namespace std; #ifdef N_N_C #include "debug.h" #else #define cebug(...) "Arya" #endif #define int long long const int N=1e5+5; const int mod=1e9+7; int n,m,a[25],b[25],dp[25][1<<20],cost[1<<20]; void sol(){ cin>>n>>m; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=m; i++) cin>>b[i]; for(int mask=0; mask<(1<<m); mask++) for(int i=0; i<m; i++) if((mask>>i)&1) cost[mask]+=b[i+1]; dp[0][0]=1; for(int i=1; i<=n; i++){ for(int mask=1; mask<(1<<m); mask++){ for(int mask2=mask; ; mask2=(mask2-1)&mask){ if(dp[i-1][mask2] and cost[mask^mask2]==a[i]){ dp[i][mask]=1; break; } if(!mask2) break; } } } for(int i=1; i<(1<<m); i++){ if(dp[n][i]){ cout<<"YES"; return; } } cout<<"NO"; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen(".inp", "r", stdin); // freopen(".out", "w", stdout); int tt=1; //cin>>tt; while(tt--){ sol(); } cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; return 0; } /** /\_/\ * (= ._.) * / >💖 \>💕 **/

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

bank.cpp:54:9: warning: "/*" within comment [-Wcomment]
   54 | /**  /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...