Submission #1131386

#TimeUsernameProblemLanguageResultExecution timeMemory
1131386ahmedsahlolBank (IZhO14_bank)C++20
0 / 100
314 ms114532 KiB
#include <bits/stdc++.h> #define int long long #define el '\n' using namespace std; void work() { int n, m; cin >> n >> m; vector<int> v(n); for (auto &i: v)cin >> i; sort(v.begin(), v.end()); priority_queue<int> pq, extra; for (int i = 1, a; i <= m; ++i) { cin >> a; pq.push(a); } for (int i = 0; i < n; ++i) { while (pq.size() && v[i] > 0) { int now = pq.top(); pq.pop(); if (v[i] >= now) { v[i] -= now; } else { extra.push(now); } } if (v[i] > 0) { cout << "NO" << el; return; } while (extra.size()) { pq.push(extra.top()); extra.pop(); } } cout << "YES" << el; } int32_t main() { #ifndef ONLINE_JUDGE freopen("D:\\Work\\input.txt", "r", stdin); freopen("D:\\Work\\output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; // cin >> tc; while (tc--) { work(); } }

Compilation message (stderr)

bank.cpp: In function 'int32_t main()':
bank.cpp:44:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     freopen("D:\\Work\\input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     freopen("D:\\Work\\output.txt", "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...