제출 #1131384

#제출 시각아이디문제언어결과실행 시간메모리
1131384ahmedsahlolBank (IZhO14_bank)C++20
0 / 100
323 ms114476 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.rbegin(), v.rend());
    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();
    }
}

컴파일 시 표준 에러 (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...