제출 #1129210

#제출 시각아이디문제언어결과실행 시간메모리
1129210wafaa_s_473은행 (IZhO14_bank)C++20
100 / 100
136 ms8520 KiB
#include <bits/stdc++.h> #define el <<'\n' ; #define Lol ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define all(v) v.begin() , v.end() #define rall(v) v.rbegin() , v.rend() #define sz(s) (int)s.size() #define int long long /* * ياا مسهل الاحوال */ using namespace std; void _3K_W_RABK_YFK(){ int n , m; cin>>n>>m ; vector<int>a(n) , b(m) , pre(1); for( auto &i:a ) cin>>i , pre.push_back(pre.back() + i); for( auto &i:b ) cin>>i ; vector<int>dp(1 << m) ; dp[0] = 0 ; int idx = 0 ; for( int msk = 1 ; msk < (1 << m) ; ++msk ){ int sum = 0 ; for( int i = 0 ; i < m ; ++i ) if( msk & (1 << i) ) sum += b[i] ; for( int i = 0 ; i < m ; ++i ){ if( msk & (1 << i) ){ int prv = dp[msk ^ (1 << i)] ; dp[msk] = max(dp[msk] , prv) ; if( prv < n and a[prv] == sum - pre[prv] ) dp[msk] = max(dp[msk] , prv + 1) ; } } idx = max(idx, dp[msk]) ; // cout<<msk<<' '<<dp[msk]<<endl; } cout<<(idx == n ? "YES" : "NO") ; } int32_t main() { Lol //#ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); //#endif int t=1 ;// cin>>t ; for( int i=1; i<=t; ++i ){ _3K_W_RABK_YFK(); } return 0; } /* practice makes PERFECT */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...