Submission #1001483

#TimeUsernameProblemLanguageResultExecution timeMemory
1001483reginoxBank (IZhO14_bank)C++17
100 / 100
527 ms47696 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 premask[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 mask = 1; mask < 1<<m; mask++){ ll sum = 0; for(ll i = 0; i < m; i++){ if(mask>>i&1) sum += b[i]; } premask[sum].push_back(mask); } memset(dp,-1,sizeof(dp)); dp[0] = 0; for (ll i = 0; i < n; i++) { for (ll mask = (1<<m)-1; mask >= 0; mask--) { if (dp[mask] != -1) { for (ll submask:premask[a[i]]) { if (!(submask&mask)) { dp[submask|mask] = dp[mask]+1; if (dp[submask|mask] == 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...