제출 #784734

#제출 시각아이디문제언어결과실행 시간메모리
784734nghiaaa은행 (IZhO14_bank)C++14
100 / 100
117 ms16900 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ii pair<int,int> #define f first #define s second #define mp make_pair multiset<int> haha; int n,m,BIT[21]; ii dp[1<<22]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); //freopen("bank.in","r",stdin); //freopen("bank.out","w",stdout); cin>>n>>m; int a[n],b[m]; for (int i=0;i<n;i++) cin>>a[i]; for (int i=0;i<m;i++) cin>>b[i]; BIT[0]=1;ii newState; for (int i=1;i<22;i++) BIT[i]=BIT[i-1]<<1; for (int mask=0;mask<BIT[m];mask++) { if (dp[mask].f==n) { cout<<"YES"; return 0; } for (int i=0;i<m;i++) { if (mask&BIT[i]) continue; if (dp[mask].s+b[i]==a[dp[mask].f]) newState=mp(dp[mask].f+1,0); else newState=mp(dp[mask].f,dp[mask].s+b[i]); dp[mask|BIT[i]]=max(dp[mask|BIT[i]],newState); } } cout<<"NO"; return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:25:15: warning: iteration 20 invokes undefined behavior [-Waggressive-loop-optimizations]
   25 |         BIT[i]=BIT[i-1]<<1;
      |         ~~~~~~^~~~~~~~~~~~
bank.cpp:24:19: note: within this loop
   24 |     for (int i=1;i<22;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...