提出 #20710494


ソースコード 拡げる

#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;
}

提出情報

提出日時
問題 E - Mex Min
ユーザ fiveAB
言語 C++ (GCC 9.2.1)
得点 500
コード長 736 Byte
結果 AC
実行時間 82 ms
メモリ 7520 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 4
AC × 28
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
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