제출 #1022232

#제출 시각아이디문제언어결과실행 시간메모리
1022232ivaziva은행 (IZhO14_bank)C++14
19 / 100
80 ms16804 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 20 long long n,m; long long a[MAXN],b[MAXN]; long long preostalo[1<<MAXN]; long long pokriveno[1<<MAXN]; int main() { cin>>n>>m; for (long long i=1;i<=n;i++) cin>>a[i]; for (long long i=1;i<=m;i++) cin>>b[i]; for (long long i=1;i<(1<<MAXN);i++) preostalo[i]=pokriveno[i]=-1; preostalo[0]=pokriveno[0]=0; for (long long suma=0;suma<(1<<m);suma++) { for (long long poslednji=0;poslednji<m;poslednji++) { if ((suma&(1<<poslednji))==0) continue; long long prethodni=suma&((1<<poslednji)-1); if (pokriveno[prethodni]==-1) continue; long long noviostatak=preostalo[prethodni]+b[poslednji]; long long plata=a[pokriveno[prethodni]+1]; if (noviostatak<plata) { pokriveno[suma]=pokriveno[prethodni]; preostalo[suma]=noviostatak; } else if (noviostatak==plata) { pokriveno[suma]=pokriveno[prethodni]+1; preostalo[suma]=0; } } if (pokriveno[suma]==n) {cout<<"YES"<<endl;return 0;} } cout<<"NO"<<endl;return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...