제출 #1127554

#제출 시각아이디문제언어결과실행 시간메모리
1127554byhtlm은행 (IZhO14_bank)C++20
100 / 100
133 ms16828 KiB
/*********************************** ██╗░░██╗████████╗██╗░░░░░███╗░░░███╗ ██║░░██║╚══██╔══╝██║░░░░░████╗░████║ ███████║░░░██║░░░██║░░░░░██╔████╔██║ ██╔══██║░░░██║░░░██║░░░░░██║╚██╔╝██║ ██║░░██║░░░██║░░░███████╗██║░╚═╝░██║ ╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═╝░░░░░╚═╝ ***********************************/ //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <unistd.h> //#include "functions.h" #define int l #define f first #define s second #define endl '\n' #define l long long #define ara <<" "<< #define pb push_back #define pairs pair<l,l> #define NO cout<<"NO"<<endl #define stop system("pause") #define YES cout<<"YES"<<endl #define all(v) v.begin(),v.end() #define yesno(v) ((v) ? "YES" : "NO") #define dbg(x) cout<<#x<<" = "<<x<<endl; #define filereader() ifstream cin(input); #define fileprinter() ofstream cout(output); #define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update> indexed_set; const l N = 2e5 + 5; const l INF = 1e18; const l mod = 1e9 + 7; const string input = "input.txt"; const string output = "output.txt"; l gcd(l a, l b){ if(b == 0){ return a; } return gcd(b,a%b); } l binpow(l a, l b) { if (b == 0) return 1; l res = binpow(a, b / 2); if (b % 2) return ((res * res) % mod * a) % mod; else return (res * res) % mod; } l dp[1<<20][2]; void solve(){ l n,m; cin>>n>>m; l a[n], b[m]; for(int i = 0 ; i < n ; i++){ cin>>a[i]; } for(int i = 0 ; i < m ; i++){ cin>>b[i]; } /* 2 6 9 10 5 4 8 6 3 7 [mask][0] = maks_ind [mask][1] = last_place [00] = {0 , 5} [00] = {0 , 4} [01] = {0 , 9} => {1 , 0} [10] = {0 , 9} => {1 , 0} */ l ans = 0; for(int i = 0; i < (1<<m);i++){ for(int j = 0; j < m ; j++){ if((1 << j ) & i){ continue; } { l nw = i | (1 << j); l t1 = dp[i][0]; l t2 = dp[i][1] + b[j]; //cout<<i<<" "<<t1<<" "<<t2<<endl; if(t1 == n){ break; } if(t2 > a[t1]){ continue; } if(t2 == a[t1]){ t1++; t2 = 0; } ans = max(ans , t1); if(dp[nw][0] == t1 and dp[nw][1] == 0 ){ dp[nw][0] = t1; dp[nw][1] = t2; } else if(dp[nw][0] < t1){ dp[nw][0] = t1; dp[nw][1] = t2; } } } } if(ans == n){ cout<<"YES"<<endl; } else{ cout<<"NO"<<endl; } } signed main(){ //fast; //srand(time(NULL)); //system("color a"); //const char* color = "color" + to_string(rand() % 10); l n = 1; //cin>>n; while(n--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...