제출 #1284387

#제출 시각아이디문제언어결과실행 시간메모리
1284387beka19은행 (IZhO14_bank)C++20
44 / 100
1096 ms584 KiB
#include <bits/stdc++.h> using namespace std; #define sped ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pb push_back #define s second #define f first const int N = 5e5 + 10; void okok(){ int n,m; cin >> n >> m; if(n > 1){ int a[n + 1]; vector < int > v; for(int i = 1;i <= n;i++) cin >> a[i]; for(int i = 1;i <= m;i++){ int x; cin >> x; v.pb(x); } sort(v.begin(),v.end()); do{ int c = 0; int j = 1; for(int to : v){ if(j > n) break; c += to; if(c > a[j]){ break; } if(c == a[j]){ j++; c = 0; } } if(j > n){ cout << "YES"; return; } } while(next_permutation(v.begin(),v.end())); cout << "NO"; return; } int x; cin >> x; int b[m + 1]; for(int i = 0;i < m;i++){ cin >> b[i]; } for(int i = 1 ;i < (1<<m);i++){ int sum = 0; for(int j = 0;j < m;j++){ if( ((1 << j) & i) != 0){ sum += b[j]; } } if(sum == x){ cout << "YES"; return; } } cout << "NO"; } signed main() { //freopen("bank.in", "r", stdin) ; //freopen("bank.out", "w", stdout); sped int tt = 1; //cin >> tt; while(tt--){ okok(); cout << '\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...