제출 #1128176

#제출 시각아이디문제언어결과실행 시간메모리
1128176ImperialALEN은행 (IZhO14_bank)C++20
19 / 100
1 ms584 KiB
#include <bits/stdc++.h> // #pragma GCC optomize ("Ofast") // #pragma GCC optomize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #define F first #define S second #define ll long long #define int long long #define pb push_back #define all(x) (x.begin(),x.end()) #define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const ll N = 2e5+9, INF = 1e18 , inf = 1e9 , mod = 1e9+7; int a[22]; int b[22]; int dp[N]; map<int,int>mp; signed main(){ // freopen("bank.in", "r", stdin); // freopen("bank.out", "w", stdout); ios; int n,m; cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; int x=0; for(int i=1;i<=m;i++){ cin>>b[i]; x+=b[i]; } if(n==1){ set<int>st; for(int i=1;i<=m;i++){ for(int pos=x;pos>=1;pos--){ if(pos-b[i]>=0){ dp[pos]=max(dp[pos],dp[pos-b[i]]+b[i]); st.insert(dp[pos]); } } } for(auto to:st)mp[to]++; if(mp[a[1]]!=0)cout<<"YES\n"; else cout<<"NO\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...