Submission #1155334

#TimeUsernameProblemLanguageResultExecution timeMemory
1155334eudhsyfBank (IZhO14_bank)C++20
0 / 100
8 ms16912 KiB
/* Author : */ #include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second #define pii pair<int, int> #define pb push_back #define eb emplace_back #define task "file" #define int ll int a[21], b[21], n, m; int dp[(1 << 20) + 5], lst[(1 << 20) + 5]; signed main () { if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 0; i < m; i++) { cin >> b[i]; } memset(dp, -1, sizeof(dp)); memset(lst, -1, sizeof(lst)); dp[0] = 0; lst[0] = 0; for (int mask = 1; mask < (1 << m); mask ++) { for (int j = 0; j < m; j++) { if(mask & (1 << j)) { int pre = mask & ~(1 << j); if(dp[pre] == -1) continue; dp[mask] = dp[pre]; if(lst[pre] + b[j] == a[dp[mask] + 1]) { dp[mask] ++; lst[mask] = 0; } else if(lst[pre] + b[j] < a[dp[mask] + 1]) { lst[mask] = lst[pre] + b[j]; } } } if(dp[mask] == n) { cout << "YES"; return 0; } } cout << "NO"; return 0; }

Compilation message (stderr)

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