Submission #20710494


Source Code Expand

#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

const int max_n = 1500000;
int prv[max_n];

#define gc getchar
inline int read()
{
	int c = gc(), t = 1, n = 0;
	while (isspace(c)) { c = gc(); }
	if (c == '-') { t = -1, c = gc(); }
	while (isdigit(c)) { n = n * 10 + c - '0', c = gc(); }
	return n * t;
}
#undef gc

int main()
{
	memset(prv, -1, sizeof prv);

	int n = read(), m = read(), tmp, ans = n;

	for (int i = 0; i < n; i++)
	{
		tmp = read();
		if (i - prv[tmp] - 1 >= m && tmp < ans)
			ans = tmp;
		
		prv[tmp] = i;
	}

	for (int i = 0; i < n; i++)
		if (n - prv[i] - 1 >= m && i < ans)
		{
			ans = i;
			break;
		}

	printf("%d\n", ans);

	return 0;
}

Submission Info

Submission Time
Task E - Mex Min
User fiveAB
Language C++ (GCC 9.2.1)
Score 500
Code Size 736 Byte
Status AC
Exec Time 82 ms
Memory 7520 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All answer_n_00.txt, answer_n_01.txt, gu_killer_00.txt, gu_killer_01.txt, gu_killer_02.txt, handmade_00.txt, handmade_01.txt, handmade_02.txt, handmade_03.txt, large_answer_00.txt, large_answer_01.txt, large_answer_02.txt, large_answer_03.txt, large_answer_04.txt, large_answer_05.txt, large_answer_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, same_00.txt, same_01.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
answer_n_00.txt AC 82 ms 7448 KiB
answer_n_01.txt AC 40 ms 7436 KiB
gu_killer_00.txt AC 47 ms 7448 KiB
gu_killer_01.txt AC 48 ms 7500 KiB
gu_killer_02.txt AC 48 ms 7520 KiB
handmade_00.txt AC 7 ms 7400 KiB
handmade_01.txt AC 11 ms 7464 KiB
handmade_02.txt AC 8 ms 7428 KiB
handmade_03.txt AC 6 ms 7516 KiB
large_answer_00.txt AC 47 ms 7520 KiB
large_answer_01.txt AC 46 ms 7476 KiB
large_answer_02.txt AC 46 ms 7520 KiB
large_answer_03.txt AC 45 ms 7520 KiB
large_answer_04.txt AC 29 ms 7404 KiB
large_answer_05.txt AC 18 ms 7428 KiB
large_answer_06.txt AC 38 ms 7408 KiB
random_00.txt AC 35 ms 7520 KiB
random_01.txt AC 38 ms 7520 KiB
random_02.txt AC 27 ms 7440 KiB
random_03.txt AC 36 ms 7496 KiB
random_04.txt AC 30 ms 7416 KiB
random_05.txt AC 10 ms 7380 KiB
same_00.txt AC 22 ms 7420 KiB
same_01.txt AC 45 ms 7516 KiB
sample_01.txt AC 9 ms 7428 KiB
sample_02.txt AC 6 ms 7476 KiB
sample_03.txt AC 7 ms 7424 KiB
sample_04.txt AC 6 ms 7408 KiB