Submission #1306970

#TimeUsernameProblemLanguageResultExecution timeMemory
1306970ng.annhaatBank (IZhO14_bank)C++20
71 / 100
1099 ms32904 KiB
/* ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░ ░░░░░░░░ ░░░░░ ░ ░ ░░░░ ░░░░░ ░░░░░░ ░░░░ ▒▒▒▒▒▒ ▒ ▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒▒▒ ▒▒▒▒ ▒▒▒ ▒▒▒▒ ▒▒ ▒▒▒▒▒ ▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒ ▒▒▒▒▒▒▒▒ ▒ ▒▒▒▒ ▒▒ ▓▓▓▓ ▓▓▓ ▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓ ▓ ▓▓▓▓▓▓ ▓▓▓ ▓ ▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓ ▓ ▓▓ ▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓ ▓▓▓ ▓▓▓▓▓ ▓▓ ▓▓▓▓ ▓▓ █ █████████ ███ ████████ █████ ████ █████ ██████ ██████ ███████████████████████████████████████████████████████████████████████████████ ▄▄▄ ███▄ █ ███▄ █ ██░ ██ ▄▄▄ ▄▄▄ ▄▄▄█████▓ ▒████▄ ██ ▀█ █ ██ ▀█ █ ▒▓██░ ██ ▒████▄ ▒████▄ ▓ ██▒ ▓▒ ▒██ ▀█▄ ▓██ ▀█ ██▒▓██ ▀█ ██▒░▒██▀▀██ ▒██ ▀█▄ ▒██ ▀█▄ ▒ ▓██░ ▒░ ░██▄▄▄▄██▓██▒ ▐▌██▒▓██▒ ▐▌██▒ ░▓█ ░██ ░██▄▄▄▄██░██▄▄▄▄██░ ▓██▓ ░ ▓█ ▓██▒██░ ▓██░▒██░ ▓██░ ░▓█▒░██▓ ▓█ ▓██ ▓█ ▓██ ▒██▒ ░ ▒▒ ▓▒█░ ▒░ ▒ ▒ ░ ▒░ ▒ ▒ ▒ ░░▒░▒ ▒▒ ▓▒█ ▒▒ ▓▒█ ▒ ░░ ░ ▒▒ ░ ░░ ░ ▒░░ ░░ ░ ▒░ ▒ ░▒░ ░ ░ ▒▒ ░ ▒▒ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ░ ▒ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ */ //#include <bits/BaoMinhTranc++.h> #include <bits/stdc++.h> #define int int64_t //#define ll int64_t #define ld long double #define ii pair<int,int> #define iii pair<int,ii> #define fi first #define se second #define ALL(x) x.begin(),x.end() #define ALLr(x) x.rbegin(),x.rend() #define upgrade ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define name "youreagoodmanarthur" using namespace std; const int Max=1<<20; const int N=23; const int INF=1e18; const int MOD=998244353; const int MOD2=1e9+8; const int base=26; const int LOG=20; template<class X,class Y> bool minimize(X& x,const Y& y) { if(x>y){ x=y; return 1; }return 0; } template<class X,class Y> bool maximize(X& x,const Y& y) { if(x<y){ x=y; return 1; }return 0; } int n,m; int a[N],b[N]; bool dp[20][Max]; vector<int> pre[20003]; void solve() { cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=0;i<m;i++)cin>>b[i]; for(int i=1;i<=n;i++)a[i]+=a[i-1]; for(int mask=1;mask<(1<<m);mask++){ int s=0; for(int i=0;i<m;i++)if(mask>>i&1)s+=b[i]; pre[s].push_back(mask); } for(int mask=0;mask<(1<<m);mask++)dp[0][mask]=1; for(int i=1;i<=n;i++){ for(int mask:pre[a[i]])dp[i][mask]=dp[i-1][mask]; for(int mask=1;mask<(1<<m);mask++)for(int j=0;j<m;j++)if(mask>>j&1)dp[i][mask]|=dp[i][mask^(1<<j)]; } if(dp[n][(1<<m)-1])cout<<"YES"; else cout<<"NO"; } void prepare() { } signed main() { upgrade if(fopen(name".INP","r")){ freopen(name".INP","r",stdin); freopen(name".OUT","w",stdout); } prepare(); int test=1; // cin>>test; while(test--)solve(); return 0; } /* ░▓▓ ░▒▒▒ ░▒▒▒▒▒▒░░░ ░▓▓ ▓▒ ▒▓▓▓▓▓▓▓▓▓▓▓▓▒ ░▓▓▓▓▓▓▓▓▓▓▓▒░ ▒▓▓▒ ▒▒▒▒░ ░░░░▒░▒▒▒▒▒▒ ░▓▓ ░░▒▒▒▒▒░░ ▒▓▓▒ ▒▓▓░ ░▓▓▒ ░▓▓▓▒ ░▒▓▓░░▓▓▒ ▒▒▒ ▒▒▒▒▒▒░░░▒▒▒▒▒▒▒▒▒▒▒░ ░▓▓▓▒▒▒▒▒▒▒▒▒▒▓▒▒░ ▓▓▓▓▒ ░▓▓▒ ▒▓▓▒ ░▓▓▓░ ░▒░ ░▒▒▒▒▒▒▒▒ ▒▒▒░ ▒▒▒ ░▓▓ ░▓▓░ ▓▓▓ ░▒▒▒ ▒▒▒ ░▒▒ ▒▓▒ ▒▓▒ ▓▓▓ ░░ ▒▒░ ▒▒▒ ▒▒░ ▓▓▓ ░▓▒ ░▓▓▓ ░▒ ▒▒░ ▒▒░ ▒▒░ ▒▒▒ ▓▓▓░ ░▓▒ ░▓▓▓▒ ▒▒▒ ░▒▒▒░ ░▒▒░ ░▒▒ ▒▒▒ ▓▓▓▒ ▒▓▒ ▓▓▓░ ░ ▒▒░ ▒▒▒ ▒▒▒▒▒▒▒▒░ ▒▒▒▒▒▒▒▒ ░▓▓▓ ░▓▓▒ ▒▓▓▓▒ ░▓▓▓▓▒ ░▒▒ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒▒▒░ ░▓▓▓ ░▒ ░▓▓▓▓▓▓▒░ ▒▓▓▓▓▓▒▓▓▒ ▒▒▒▒▒▒▒░ ░▒▒▒▒▒▒▒░ ▓▓▓▓▒▒ ▒▓▓▓▓ ░░▓▓▓▓▓▓▓▓▒░░ ▒▓▒ ░▒▒▒▒░ ░▒▓▓▓▓▓▓▓▓▒░ ▒▓▓░ ▒▒░ ▓▒ ▒▓▓░ ▒▒▒░ ▓▓▒ ░▓▓▒ ░▒▒▒▒ ▓▓▓░ ▒▓▓▓ ░▒▒▒ ░▓▓▓▓░ ░▓▓▓▒ ░▓▓▓▓▓▒▒░░░ ░░░▒▒▓▓▓▓░ ░▒▒▒▒▒▒▒▒░ */

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...