제출 #501416

#제출 시각아이디문제언어결과실행 시간메모리
501416IOI_champion_in_1980은행 (IZhO14_bank)C++14
0 / 100
1091 ms332 KiB
#include <bits/stdc++.h> #include <math.h> typedef long long ll; using namespace std; ll i, j, t, a, n, m, b, c, d, f, g; int main() { ios::sync_with_stdio(0); cin.tie(0); cin>>n>>m; map <int, int> mpn; vector <int> vm(m); for (a=1; a<=n; a++) { cin>>c; mpn[c]=a; } for (a=0; a<m; a++) { cin>>vm[a]; } if (n>m) { cout<<"NO"<<endl; return 0; } vector <int> vc(m); set<int> s; for (a=0; a<m; a++) vc[a]=a; do { s.clear(); int c=0, jem=0; for (a=0; a<m; a++) { jem=jem+vm[vc[a]]; if (mpn[jem]!=0 and !s.count(mpn[jem])) { s.insert(mpn[jem]); c++; jem=0; } } if (c==n) { cout<<"YES"<<endl; return 0; } } while(next_permutation(vc.begin(), vc.end())); cout<<"NO"<<endl; } /* 1 5 8 4 2 5 1 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...