18902022-12-07 11:05:47peterRendőrségi Üldözés 4cpp17Wrong answer 0/1002.599s3844 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 >= meglampa)
				{
					athaladhat--;
					koordinata++;
				}
				else
				{
					
				}
			}
			meglampa--;
		}
		else
		{
			koordinata++;
		}
		ido++;

	} while (koordinata < utcahossz);

	printf("%d", ido);

	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1364 KiB
2Wrong answer2ms1624 KiB
subtask20/10
3Time limit exceeded2.598s1836 KiB
4Time limit exceeded2.563s2000 KiB
5Time limit exceeded2.559s2104 KiB
6Time limit exceeded2.579s2240 KiB
7Time limit exceeded2.548s2512 KiB
subtask30/15
8Time limit exceeded2.575s2996 KiB
9Time limit exceeded2.566s2532 KiB
10Time limit exceeded2.578s2876 KiB
11Time limit exceeded2.552s3156 KiB
subtask40/15
12Wrong answer2ms2940 KiB
13Wrong answer2ms3040 KiB
14Wrong answer2ms3148 KiB
15Wrong answer2ms3000 KiB
subtask50/25
16Wrong answer2ms3068 KiB
17Wrong answer2ms3308 KiB
18Wrong answer2ms3392 KiB
19Wrong answer2ms3472 KiB
20Wrong answer2ms3544 KiB
subtask60/15
21Time limit exceeded2.599s3480 KiB
22Time limit exceeded2.539s3704 KiB
23Time limit exceeded2.563s3680 KiB
24Time limit exceeded2.562s3344 KiB
25Time limit exceeded2.572s3632 KiB
subtask70/20
26Time limit exceeded2.575s3532 KiB
27Time limit exceeded2.572s3844 KiB
28Time limit exceeded2.575s3672 KiB
29Time limit exceeded2.559s3840 KiB
30Time limit exceeded2.572s3844 KiB