18882022-12-07 10:53:25peterRendőrségi Üldözés 4cpp17Wrong answer 0/1002.598s3808 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

bool zolde(int ido, int periodus)
{
	return ido % (2 * periodus) < periodus;	
}

bool lampae(int koordinata, int* lampak, int lampakszama)
{
	for (int i = 0; i < lampakszama; i++)
	{
		if (lampak[i] == koordinata)
		{
			return true;
		}
	}
	return false;
}

int main()
{
	int lampakszama, athaladhat, periodusfele, utcahossz;
	scanf("%d %d %d %d", &lampakszama, &athaladhat, &periodusfele, &utcahossz);

	int* koordinatak = (int*)malloc(sizeof(int) * lampakszama);
	for (int i = 0; i < lampakszama; i++)
	{
		scanf("%d", &koordinatak[i]);
	}

	int ido = 0;
	int koordinata = 0;
	int meglampa = lampakszama;

	do
	{
		if (lampae(koordinata, koordinatak, lampakszama))
		{

			if (zolde(ido, periodusfele))
			{
				koordinata++;
			}
			else
			{
				if (athaladhat == 0)
				{
					; // üres --> várakozik a lámpánál
				}
				else if (athaladhat == meglampa)
				{
					athaladhat--;
					koordinata++;
				}
				else {
					
				}
			}
			meglampa--;
		}
		else
		{
			koordinata++;
		}
		ido++;

	} while (koordinata < utcahossz);

	printf("%d", ido);

	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1292 KiB
2Accepted2ms1548 KiB
subtask20/10
3Time limit exceeded2.598s1944 KiB
4Time limit exceeded2.555s1532 KiB
5Time limit exceeded2.516s2024 KiB
6Time limit exceeded2.582s2000 KiB
7Time limit exceeded2.543s1680 KiB
subtask30/15
8Time limit exceeded2.539s2000 KiB
9Time limit exceeded2.571s2300 KiB
10Time limit exceeded2.568s2344 KiB
11Time limit exceeded2.572s2204 KiB
subtask40/15
12Wrong answer2ms2580 KiB
13Wrong answer2ms2724 KiB
14Wrong answer2ms2596 KiB
15Wrong answer2ms2648 KiB
subtask50/25
16Wrong answer2ms2592 KiB
17Wrong answer2ms2652 KiB
18Wrong answer2ms2864 KiB
19Wrong answer2ms2912 KiB
20Wrong answer2ms3032 KiB
subtask60/15
21Time limit exceeded2.598s3180 KiB
22Time limit exceeded2.582s3212 KiB
23Time limit exceeded2.543s3676 KiB
24Time limit exceeded2.559s3464 KiB
25Time limit exceeded2.548s3724 KiB
subtask70/20
26Time limit exceeded2.559s3724 KiB
27Time limit exceeded2.575s3588 KiB
28Time limit exceeded2.563s3776 KiB
29Time limit exceeded2.559s3472 KiB
30Time limit exceeded2.559s3808 KiB