58722023-10-04 17:38:36horkaUtazásszervezés (75 pont)cpp11Accepted 75/756ms4348 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int vez,k,m,c; cin>>vez>>k>>m>>c;
	vector<int> igeny(c+1),napok(k+1);
	for(int i=1; i<=c; i++)
		{
			cin>>igeny[i];
			napok[igeny[i]]++;
		}
	vector<int> novel(k+2);
	int mo=0;
	for(int i=1; i<=k; 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;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1816 KiB
2Accepted0/06ms2452 KiB
3Accepted3/32ms2084 KiB
4Accepted4/42ms2212 KiB
5Accepted4/42ms2424 KiB
6Accepted4/42ms2576 KiB
7Accepted4/43ms2772 KiB
8Accepted4/43ms3160 KiB
9Accepted5/53ms3132 KiB
10Accepted5/53ms3436 KiB
11Accepted6/64ms3568 KiB
12Accepted6/64ms4020 KiB
13Accepted6/64ms4180 KiB
14Accepted6/64ms4072 KiB
15Accepted6/66ms4084 KiB
16Accepted6/66ms4296 KiB
17Accepted6/66ms4348 KiB