Submission #880906

#TimeUsernameProblemLanguageResultExecution timeMemory
880906gazizmadi11Bank (IZhO14_bank)C++14
0 / 100
2 ms348 KiB
//gm --- akezhon #include <bits/stdc++.h> //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define int long long #define pb push_back #define F first #define S second #define all(v) v.begin(),v.end() #define pii pair<int,int> #define tm (tl+tr)/2 #define TL v+v, tl, tm #define TR v+v+1, tm+1, tr #define DA l <= tl && tr <= r #define NE r < tl || tr < l #define double long double using namespace std; const int N=1e5+7; const int mod=1e9+7; const int inf=1e18; int n, m; int a[30]; int b[30]; int dp[N]; void AlemAmenov(){ cin >> n >> m; for(int i=1; i <= n; i++){ cin >> a[i]; a[i] += a[i-1]; } for(int i=1; i < m; i++)cin >> b[i]; for(int mask=1; mask < (1<<m); mask++){ int s=0, x=0; for(int i=1; i <= m; i++)if((1<<(i-1))&mask)s+=b[i]; for(int i=1; i <= n; i++)if(s == a[i])x = i; if(!x){ for(int i=1; i <= m; i++){ if((1<<(i-1))&mask)dp[mask] = (dp[mask - (1<<(i-1))], dp[mask]); } } else { for(int i=1; i <= m; i++){ if((1<<(i-1))&mask && dp[mask-(1<<(i-1))] == x-1)dp[mask] = x; } } if(dp[mask] == n){ cout << "YES"; return; } } cout << "NO"; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int RealName=1; // cin >> RealName; // int C=0; while(RealName--){ // cout << "Case " << ++C << ":\n"; AlemAmenov(); } return 0; }

Compilation message (stderr)

bank.cpp: In function 'void AlemAmenov()':
bank.cpp:39:56: warning: left operand of comma operator has no effect [-Wunused-value]
   39 |     if((1<<(i-1))&mask)dp[mask] = (dp[mask - (1<<(i-1))], dp[mask]);
      |                                    ~~~~~~~~~~~~~~~~~~~~^
bank.cpp: In function 'int main()':
bank.cpp:59:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |   freopen("bank.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:60:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |   freopen("bank.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...