Submission #1098313

#TimeUsernameProblemLanguageResultExecution timeMemory
1098313vjudge1Bank (IZhO14_bank)C++17
0 / 100
0 ms604 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define io ios_base::sync_with_stdio(0),cin.tie(0); #define str string using namespace std; const int maxn=1e6+2; int t, n , m, a[1003],b[1003],sum; signed main() { io; cin >> n>> m; for(int i = 1; i <= n ; i++){ cin >> a[i]; } for(int j = 1; j <= m ;j++){ cin >> b[j]; }sort( b + 1 , b + m + 1); int cnt = 0; for(int i = 1 ; i <= n ; i++){ for(int j = 1 ; j <= m ; j++){ int l = 1 , r = m; while(l <= r){ int md = (l + r)/ 2 ; if(b[md] == a[i]){ cout << "YES" ; return 0; }else if( b[md] > a[i]){ r = md - 1; }else{ l = md + 1; } } for(int j = 1; j <= m ;j++ ){ next_permutation(b + 1 , b + m + 1); sum = 0; bool k = 0; for(int h = 1 ; h <= m ; h++){ sum+=b[h]; if(sum == a[i]){ cnt++; k = 1; break; } } if(k)break; } } } if(cnt == 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...