Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<bits/stdc++.h>
- #include<iostream>
- #include<fstream>
- #include<vector>
- #include<algorithm>
- #define long long long
- #define nln '\n'
- const long N = 2*1e5+10;
- using namespace std;
- // Global variables: f1, f2, n, a
- fstream f1, f2;
- inline void openf()
- {
- f1.open("unique.inp", ios:: in);
- f2.open("unique.out", ios:: out);
- }
- inline void closef()
- {
- f1.close();
- f2.close();
- }
- long n;
- vector<pair<long, long>> a;
- void data()
- {
- f1.tie(0)->sync_with_stdio(0);
- f2.tie(0)->sync_with_stdio(0);
- cin.tie(0)->sync_with_stdio(0);
- cin >> n;
- for (long i = 0; i != n; ++i)
- {
- long x;
- cin >> x;
- a.push_back({x, i+1});
- }
- }
- long ans = -1;
- void process()
- {
- sort(a.begin(), a.end());
- //for (const auto &i : a)
- // cout << i.second << " - " << i.first << nln;
- if (n == 1)
- {
- ans = 1;
- return;
- }
- if (a[0].first != a[1].first)
- {
- ans = a[0].second;
- return;
- }
- for (long i = 1; i != n-1; ++i)
- {
- if (a[i].first != a[i-1].first && a[i].first != a[i+1].first)
- {
- ans = a[i].second;
- return;
- }
- }
- if (a[n-1].first != a[n-2].first)
- {
- ans = a[n-1].second;
- return;
- }
- }
- void view()
- {
- cout << ans << nln;
- }
- int main()
- {
- openf();
- data();
- process();
- view();
- closef();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment