59162023-10-05 17:20:52QkrisiVállalkozócpp11Accepted 40/4076ms5660 KiB
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

vector<int> readline()
{
    string input;
    getline(cin, input);
    vector<int> numbers;
    istringstream stream(input);
    int number;
    while (stream >> number)
        numbers.push_back(number);
    return numbers;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    auto templine = readline();

    int N = templine[0];
    int M = templine[1];
    auto T = readline();

    priority_queue<int, std::vector<int>, std::greater<int>> jobs;
    for(int i = 0;i<M;i++)
      jobs.push(readline()[0]);
    int f = 0;
    for(int i = 0;i<N;i++)
      {
        int m = T[i];
        int c = 0;
        while(c < m && !jobs.empty())
          {
            int j = jobs.top();
            jobs.pop();
            if(j - 1 < i)
              continue;
            f++;
            c++;
          }
      }
    cout << f;
  
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1832 KiB
2Accepted0/076ms3356 KiB
3Accepted2/23ms2640 KiB
4Accepted2/23ms2856 KiB
5Accepted2/22ms2836 KiB
6Accepted2/24ms3012 KiB
7Accepted2/27ms3224 KiB
8Accepted2/24ms2964 KiB
9Accepted2/26ms2996 KiB
10Accepted2/23ms3252 KiB
11Accepted2/24ms3284 KiB
12Accepted2/24ms3392 KiB
13Accepted2/28ms3736 KiB
14Accepted2/26ms3888 KiB
15Accepted2/225ms4096 KiB
16Accepted2/224ms4304 KiB
17Accepted2/226ms4872 KiB
18Accepted2/217ms4840 KiB
19Accepted2/220ms4924 KiB
20Accepted2/239ms5092 KiB
21Accepted2/254ms5512 KiB
22Accepted2/276ms5660 KiB