제출 #800387

#제출 시각아이디문제언어결과실행 시간메모리
800387ttamx은행 (IZhO14_bank)C++14
100 / 100
102 ms8532 KiB
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> p2; const int N=25; const int K=(1<<20)+5; int n,m; int a[N],b[N]; p2 dp[K]; int main(){ cin.tie(nullptr)->sync_with_stdio(false); 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 i=1;i<1<<m;i++)dp[i]={-1,-1}; dp[0]={0,0}; for(int i=1;i<1<<m;i++){ for(int j=0;j<m;j++){ if(!(i>>j&1))continue; int u=i^(1<<j); auto [id,val]=dp[u]; if(id==-1)continue; if(val+b[j]==a[id]){ dp[i]={id+1,0}; }else if(val+b[j]<a[id]){ dp[i]={id,val+b[j]}; } } if(dp[i].first==n){ cout << "YES\n"; exit(0); } } cout << "NO\n"; }

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

bank.cpp: In function 'int main()':
bank.cpp:25:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |             auto [id,val]=dp[u];
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...