Submission #20733670


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<string>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int N, M;
int A[1500000 + 100];
vector<vector<int>> cnt;

int main() {
	cin >> N >> M;
	cnt.resize(N);
	for (int i = 0; i < N; i++) {
		cnt[i].push_back(-1);
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cnt[A[i]].push_back(i);
	}
	for (int i = 0; i < N; i++) {
		cnt[i].push_back(N);
	}
	
	int ans = -114514;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < cnt[i].size(); j++) {
			if (cnt[i][j] - cnt[i][j - 1] > M) {
				ans = i;
			}
		}
		if (ans != -114514)break;
	}
	if (ans == -114514)ans = N;

	cout << ans << endl;

	return 0;
}

Submission Info

Submission Time
Task E - Mex Min
User Sen
Language C++ (GCC 9.2.1)
Score 500
Code Size 784 Byte
Status AC
Exec Time 1156 ms
Memory 99740 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   34 |   for (int j = 1; j < cnt[i].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~

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 1156 ms 91032 KB
answer_n_01.txt AC 529 ms 48860 KB
gu_killer_00.txt AC 472 ms 91080 KB
gu_killer_01.txt AC 473 ms 91104 KB
gu_killer_02.txt AC 466 ms 90984 KB
handmade_00.txt AC 3 ms 3568 KB
handmade_01.txt AC 2 ms 3592 KB
handmade_02.txt AC 3 ms 3652 KB
handmade_03.txt AC 2 ms 3592 KB
large_answer_00.txt AC 477 ms 93356 KB
large_answer_01.txt AC 472 ms 91100 KB
large_answer_02.txt AC 484 ms 91016 KB
large_answer_03.txt AC 470 ms 90972 KB
large_answer_04.txt AC 223 ms 46320 KB
large_answer_05.txt AC 99 ms 20356 KB
large_answer_06.txt AC 354 ms 66788 KB
random_00.txt AC 309 ms 97484 KB
random_01.txt AC 399 ms 99740 KB
random_02.txt AC 291 ms 96952 KB
random_03.txt AC 308 ms 77520 KB
random_04.txt AC 273 ms 51744 KB
random_05.txt AC 17 ms 6204 KB
same_00.txt AC 302 ms 97760 KB
same_01.txt AC 459 ms 97724 KB
sample_01.txt AC 3 ms 3528 KB
sample_02.txt AC 2 ms 3596 KB
sample_03.txt AC 2 ms 3412 KB
sample_04.txt AC 4 ms 3404 KB