| 20852 | 2026-01-10 10:58:10 | ProgramozoRoka | Késés | cpp17 | Compilation error |
#include <bits/stdc++.h>
using namespace std;
int n,a[200000];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<int> b;
cin>>n;
b.reserve(200000);
for(int i=0; i<n; ++i)
{
cin>>a[i];
b.push_back(a[i]);
}
sort(b.begin(), b.end());
b.erase(unique(b.begin(), b.end()), b.end());
int meret=b.size();
vector<bool> pipa(meret,false);
int talalat=0;
for(int i=n-1;i>=0;--i)
{
auto it=lower_bound(b.begin(),b.end(),a[i]);
int index = distance(b.begin(), it);
// Csak akkor csökkentjük a hátralévők számát, ha ezt az évszámot MOST látjuk először hátulról
if (!pipa[index]) {
pipa[index] = true;
talalt++;
}
// Ha az összes különböző évszámot "kipipáltuk"
if (talalt == meret) {
cout << i + 1 << endl;
return 0;
}
}
return 0;
}
open /var/local/lib/isolate/436/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:37:13: error: 'talalt' was not declared in this scope; did you mean 'talalat'?
37 | talalt++;
| ^~~~~~
| talalat
main.cpp:41:13: error: 'talalt' was not declared in this scope; did you mean 'talalat'?
41 | if (talalt == meret) {
| ^~~~~~
| talalat