제출 #82905

#제출 시각아이디문제언어결과실행 시간메모리
82905ToadDaveski은행 (IZhO14_bank)C++14
19 / 100
2 ms1492 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll dp[45][45][2501],a[45],b[45]; int main() { ll n,m,i,j,g; cin>>n>>m; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=m;i++) cin>>b[i]; sort(a+1,a+n+1); sort(b+1,b+n+1); dp[0][0][0]=1; for(i=1;i<=m;i++) for(j=0;j<=n;j++) { for(g=0;g<=a[j];g++) { dp[i][j][g]=dp[i-1][j][g]; if (g==b[i]) dp[i][j][g]=max(dp[i][j][g],dp[i-1][j-1][a[j-1]]); if (g>b[i])dp[i][j][g]=max(dp[i][j][g],dp[i-1][j][g-b[i]]); } } if (dp[m][n][a[n]]) cout<<"YES"; else cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...