1842021-02-03 22:29:27kovacs.peter.18fKéséscpp11Elfogadva 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';
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms1752 KiB
2Elfogadva0/04ms2080 KiB
3Elfogadva5/51ms1836 KiB
4Elfogadva5/51ms1836 KiB
5Elfogadva5/537ms4752 KiB
6Elfogadva5/539ms4752 KiB
7Elfogadva4/443ms4748 KiB
8Elfogadva4/446ms4752 KiB
9Elfogadva4/443ms4752 KiB
10Elfogadva4/443ms4752 KiB
11Elfogadva4/443ms4752 KiB
12Elfogadva2/246ms4752 KiB
13Elfogadva2/243ms4752 KiB
14Elfogadva1/143ms4752 KiB
15Elfogadva1/145ms4748 KiB
16Elfogadva1/145ms4756 KiB
17Elfogadva1/146ms4748 KiB
18Elfogadva1/150ms4748 KiB
19Elfogadva1/148ms4752 KiB