55942023-08-02 13:09:56TomaSajtUtazásszervezés (75 pont)cpp17Accepted 75/756ms5584 KiB
#include <bits/stdc++.h>
using namespace std;

const int K_MAX = 100000;

int main() {
  int guides, k, m, c;
  cin >> guides >> k >> m >> c;

  vector<int> requests(K_MAX + 1, 0);
  for (int i = 0; i < c; i++) {
    int s;
    cin >> s;
    // if (s > k - m + 1) continue;  // This should not happen, but it does!!!!
    requests[s] += 1;
  }

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

  for (int s = 1; s <= K_MAX - 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/04ms3164 KiB
2Accepted0/06ms3372 KiB
3Accepted3/33ms3584 KiB
4Accepted4/44ms3796 KiB
5Accepted4/44ms4012 KiB
6Accepted4/43ms4240 KiB
7Accepted4/43ms4296 KiB
8Accepted4/43ms4504 KiB
9Accepted5/54ms4720 KiB
10Accepted5/54ms4932 KiB
11Accepted6/64ms5144 KiB
12Accepted6/66ms5164 KiB
13Accepted6/66ms5280 KiB
14Accepted6/66ms5368 KiB
15Accepted6/66ms5364 KiB
16Accepted6/66ms5368 KiB
17Accepted6/66ms5584 KiB