11042022-03-03 18:26:45peti1234Vállalkozócpp14Accepted 40/4017ms5284 KiB
#include <bits/stdc++.h>

using namespace std;
int n, m, valasz;
priority_queue<int, vector<int>, greater<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.begin(), h.end());
    // 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();
        }
    }
    cout << valasz << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/02ms1880 KiB
2Accepted0/017ms3612 KiB
3Accepted2/21ms2308 KiB
4Accepted2/21ms2312 KiB
5Accepted2/21ms2316 KiB
6Accepted2/22ms2368 KiB
7Accepted2/23ms2412 KiB
8Accepted2/21ms2400 KiB
9Accepted2/22ms2432 KiB
10Accepted2/21ms2412 KiB
11Accepted2/22ms2444 KiB
12Accepted2/22ms2448 KiB
13Accepted2/22ms2500 KiB
14Accepted2/22ms2516 KiB
15Accepted2/26ms2860 KiB
16Accepted2/26ms2968 KiB
17Accepted2/27ms3644 KiB
18Accepted2/24ms3440 KiB
19Accepted2/27ms3576 KiB
20Accepted2/210ms4152 KiB
21Accepted2/214ms4884 KiB
22Accepted2/217ms5284 KiB