Submission #550760

#TimeUsernameProblemLanguageResultExecution timeMemory
550760Karnis_052Bank (IZhO14_bank)C++17
0 / 100
64 ms34052 KiB
// Bismillahir Rahmanir Rahim #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int>PI; typedef pair<ll, ll > PL; typedef vector<int>VI; typedef vector<ll>VL; #define FF first #define SS second const int mod = 1e9 + 7; const int INF = 1e9; const int N = 20; ll dp[(1 << N) + 5]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); freopen("bank.in", "r", stdin); freopen("bank.out", "w", stdout); int n, m; cin >> n >> m; int a[n], b[m]; multiset<int, greater<int>>st; for (int i = 0; i < n; i++)cin >> a[i]; for (int i = 0; i < m; i++) { cin >> b[i]; st.insert(b[i]); } sort(b, b + m); reverse(b, b + m); dp[0] = 1; for (int mask = 0; mask < (1 << n); mask++) { if (!dp[mask]) continue; for (int i = 0; i < n; i++) { if ((mask >> i) & 1)continue; int sum = a[i]; for (int j = 0; j < m; j++) { if (sum >= b[j]) sum -= b[j], b[j] = 0; } if (sum == 0) dp[mask | (1 << i)] = 1; } } if (dp[(1 << n) - 1]) cout << "YES" << endl; else cout << "NO" << endl; cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; return 0; }

Compilation message (stderr)

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