Submission #1101443

#TimeUsernameProblemLanguageResultExecution timeMemory
1101443dead0neBank (IZhO14_bank)C++17
0 / 100
56 ms35772 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define endl "\n" #define all(x) x.begin(), x.end() #define int long long #define ii pair<long long,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define mid (l+r)/2 #define inf 1e15 #define MOD 1000000007 #define MX 1505 using namespace std; void solve(){ int n,m; cin >> n >> m; int pref[n], moni[m]; for(int i=0; i<n; i++) cin >> pref[i]; for(int i=1; i<n; i++) pref[i]+=pref[i-1]; for(int i=0; i<m; i++) cin >> moni[i]; int dp[1<<m]; dp[0]=-1; for(int i=1; i<1<<m; i++){ dp[i]=-1; int sum=0; for(int j=0; j<m; j++) if(i&1<<j) sum+=moni[j]; for(int j=0; j<m; j++){ if(!(i&1<<j)) continue; dp[i]=max(dp[i], dp[i^1<<j]); if(sum==pref[dp[i^1<<j]+1]) dp[i]=max(dp[i], dp[i^1<<j]+1); if(dp[i]==n-1){ cout << "YES\n"; return; } } } cout << "NO\n"; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #endif freopen("bank.in","r",stdin); freopen("bank.out","w",stdout); int t=1; //cin >> t; while(t--) solve(); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     freopen("bank.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bank.cpp:55:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     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...