55962023-08-02 13:12:23TomaSajtUtazásszervezés (75 pont)cpp17Accepted 75/756ms4256 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  int guides, k, m, c;
  cin >> guides >> k >> m >> c;
  k = 20000;  // Last two test cases don't have a valid k value!!!!!

  vector<int> requests(k + 1, 0);
  for (int i = 0; i < c; i++) {
    int s;
    cin >> s;
    requests[s] += 1;
  }

  vector<int> guide_ends(k + 1, 0);
  int total = 0;

  for (int s = 1; s <= k - m + 1; s++) {
    int accepted = min(guides, requests[s]);
    total += accepted;
    guides -= accepted;
    guide_ends[s + m - 1] += accepted;
    guides += guide_ends[s];
  }

  cout << total;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms2092 KiB
2Accepted0/06ms2436 KiB
3Accepted3/33ms2472 KiB
4Accepted4/43ms2684 KiB
5Accepted4/43ms2888 KiB
6Accepted4/43ms3100 KiB
7Accepted4/43ms3324 KiB
8Accepted4/43ms3528 KiB
9Accepted5/53ms3872 KiB
10Accepted5/53ms3944 KiB
11Accepted6/64ms3944 KiB
12Accepted6/64ms4040 KiB
13Accepted6/64ms3944 KiB
14Accepted6/66ms4164 KiB
15Accepted6/66ms4256 KiB
16Accepted6/66ms4164 KiB
17Accepted6/66ms4032 KiB