Submission #557335

#TimeUsernameProblemLanguageResultExecution timeMemory
557335Tien_NoobBank (IZhO14_bank)C++17
100 / 100
603 ms4524 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" #define Log2(x) 31 - __builtin_clz(x) using namespace std; const int N = 20; int dp[1 << N]; int a[N], b[N], n, m; void read() { cin >> n >> m; for (int i = 0; i < n; ++ i) { cin >> a[i]; } for (int i = 0; i < m; ++ i) { cin >> b[i]; } } void solve() { memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < n; ++ i) { for (int mask = 0; mask < (1 << m); ++ mask) { if (dp[mask] != -1) { for (int j = 0; j < m; ++ j) { if (((mask >> j) & 1) == 0) { dp[mask | (1 << j)] = dp[mask] + b[j]; } } } } for (int mask = 0; mask < (1 << m); ++ mask) { if (dp[mask] == a[i]) { dp[mask] = 0; } else { dp[mask] = -1; } } } for (int mask = 0; mask < (1 << m); ++ mask) { if (dp[mask] == 0) { cout << "YES"; return ; } } cout << "NO"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...