1822021-02-03 22:24:02kovacs.peter.18fKéséscpp11Accepted 50/50206ms24016 KiB
#include <iostream>
#include <stack>
#include <set>

using namespace std;

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

	int N;
	cin >> N;
	stack<int> yearS;
	for (int i = 0; i < N; i++) {
		int year;
		cin >> year;
		yearS.push(year);
	}
	set<int> countedS;
	int minimum;
	for (int i = N; i > 0; i--) {
		if (countedS.count(yearS.top()) == 0) {
			countedS.insert(yearS.top());
			minimum = i;
		}
		yearS.pop();
	}
	cout << minimum << '\n';
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1756 KiB
2Accepted0/08ms2784 KiB
3Accepted5/51ms2000 KiB
4Accepted5/51ms1996 KiB
5Accepted5/534ms4460 KiB
6Accepted5/535ms5216 KiB
7Accepted4/4143ms16504 KiB
8Accepted4/4148ms16228 KiB
9Accepted4/4137ms15096 KiB
10Accepted4/4127ms15364 KiB
11Accepted4/4123ms15224 KiB
12Accepted2/2128ms15152 KiB
13Accepted2/2181ms24016 KiB
14Accepted1/1206ms23704 KiB
15Accepted1/1194ms23376 KiB
16Accepted1/1188ms20460 KiB
17Accepted1/1123ms16772 KiB
18Accepted1/163ms9288 KiB
19Accepted1/157ms8872 KiB