1842021-02-03 22:29:27kovacs.peter.18fKéséscpp11Accepted 50/5050ms4756 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct year {
	int number;
	int index;
};

int main() {
	cin.sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	vector<year> yearS(N);
	for (int i = 0; i < N; i++) {
		cin >> yearS[i].number;
		yearS[i].index = i;
	}
	sort(yearS.begin(), yearS.end(), [](year a, year b) {
		if (a.number != b.number) {
			return a.number < b.number;
		}
		return a.index < b.index;
	});
	int last_number = 0;
	int current_maximum = N;
	int minimum = N;
	for (auto e : yearS) {
		if (e.number != last_number) {
			minimum = min(minimum, current_maximum);
			last_number = e.number;
		}
		current_maximum = e.index + 1;
	}
	minimum = min(minimum, current_maximum);
	cout << minimum << '\n';
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms1752 KiB
2Accepted0/04ms2080 KiB
3Accepted5/51ms1836 KiB
4Accepted5/51ms1836 KiB
5Accepted5/537ms4752 KiB
6Accepted5/539ms4752 KiB
7Accepted4/443ms4748 KiB
8Accepted4/446ms4752 KiB
9Accepted4/443ms4752 KiB
10Accepted4/443ms4752 KiB
11Accepted4/443ms4752 KiB
12Accepted2/246ms4752 KiB
13Accepted2/243ms4752 KiB
14Accepted1/143ms4752 KiB
15Accepted1/145ms4748 KiB
16Accepted1/145ms4756 KiB
17Accepted1/146ms4748 KiB
18Accepted1/150ms4748 KiB
19Accepted1/148ms4752 KiB