58892023-10-04 18:17:41horkaUtazásszervezés (75 pont)cpp17Accepted 75/756ms4396 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int vez,k,m,c; cin>>vez>>k>>m>>c;
	vector<int> napok(k+100);
	for(int i=1; i<=c; i++)
		{
			int x; cin>>x;
			napok[x]++;
		}
	vector<int> novel(k+100);
	int mo=0;
	for(int i=1; i<=k-m+1; i++)
	{
		vez+=novel[i];
		if(napok[i]==0 || vez==0) continue;
		if(napok[i]>=vez)
		{
			novel[i+m]+=vez;
			mo+=vez;
			vez=0;
		}
		else
		{
			novel[i+m]+=napok[i];
			mo+=napok[i];
			vez-=napok[i];
		}
	}
	cout<<mo<<endl;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1812 KiB
2Accepted0/06ms2344 KiB
3Accepted3/33ms2232 KiB
4Accepted4/43ms2440 KiB
5Accepted4/43ms2592 KiB
6Accepted4/43ms2792 KiB
7Accepted4/42ms2840 KiB
8Accepted4/43ms2920 KiB
9Accepted5/53ms3220 KiB
10Accepted5/53ms3204 KiB
11Accepted6/64ms3448 KiB
12Accepted6/64ms3680 KiB
13Accepted6/64ms3888 KiB
14Accepted6/66ms4104 KiB
15Accepted6/66ms4188 KiB
16Accepted6/66ms4188 KiB
17Accepted6/66ms4396 KiB