Submission #1001488

#TimeUsernameProblemLanguageResultExecution timeMemory
1001488reginoxBank (IZhO14_bank)C++17
19 / 100
77 ms46612 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> #define task "test" using namespace std; const int maxn = 20; ll n,m,dp[1<<21],a[21],b[21]; vi v[1000005]; int main(){ if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(ll i = 0; i < n; i++) cin >> a[i]; for(ll i = 0; i < m; i++) cin >> b[i]; for(ll msk = 1; msk < 1<<m; msk++){ ll sum = 0; for(ll i = 0; i < m; i++){ if(msk>>i&1) sum += b[i]; } v[sum].push_back(msk); } memset(dp,-1,sizeof(dp)); dp[0] = 0; for(ll i = 0; i < n; i++){ for(ll msk = 0; msk < 1<<m; msk++){ if(dp[msk] == 1) continue; for(ll sub:v[a[i]]){ if(sub & msk) continue; dp[sub|msk] = dp[msk]+1; if(dp[sub|msk] == n){ cout << "YES"; return 0; } } } } cout << "NO"; return 0; }

Compilation message (stderr)

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