11002022-03-02 21:26:23peti1234Vállalkozócpp14Wrong answer 32/4017ms5268 KiB
#include <bits/stdc++.h>

using namespace std;
int n, m, valasz;
priority_queue<int>q;
vector<int> h;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        int x;
        cin >> x;
        for (int j=1; j<=x; j++) {
            q.push(i);
        }
    }
    // q-ban a szabad orak, novekvo sorrendben (a nap szerint)

    for (int i=1; i<=m; i++) {
        int x;
        cin >> x;
        h.push_back(x);
    }
    sort(h.rbegin(), h.rend());
    // h-ban vannak a hataridok novekvo sorrendben

    for (auto x:h) {
        if (q.size()>0 && q.top()<=x) {
            // mukodik a moho strategia, ha meg lehet csinalni a legsurgosebb munkat, akkor erdemes
            valasz++;
            q.pop();
        }
        while (q.size()>0 && q.top()>x) {
            q.pop();
        }
    }
    cout << valasz << "\n";
    return 0;
}
/*
3 5
2 0 6
2
3
1
2
3
*/
SubtaskSumTestVerdictTimeMemory
base32/40
1Accepted0/02ms1820 KiB
2Accepted0/017ms3612 KiB
3Accepted2/21ms2300 KiB
4Wrong answer0/21ms2308 KiB
5Accepted2/21ms2312 KiB
6Wrong answer0/22ms2360 KiB
7Wrong answer0/22ms2404 KiB
8Accepted2/22ms2384 KiB
9Accepted2/22ms2420 KiB
10Wrong answer0/21ms2400 KiB
11Accepted2/22ms2440 KiB
12Accepted2/22ms2440 KiB
13Accepted2/23ms2492 KiB
14Accepted2/22ms2512 KiB
15Accepted2/26ms2980 KiB
16Accepted2/26ms2956 KiB
17Accepted2/27ms3636 KiB
18Accepted2/24ms3436 KiB
19Accepted2/26ms3564 KiB
20Accepted2/29ms4136 KiB
21Accepted2/212ms4864 KiB
22Accepted2/216ms5268 KiB