Advertisement
tuki2501

fcb030_unique.cpp

Nov 9th, 2021
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 200005;
  5.  
  6. int n, a[N];
  7.  
  8. template<typename T>
  9. bool chmin(T &a, T b) {
  10.   return a > b ? a = b, 1 : 0;
  11. }
  12.  
  13. int main() {
  14.   cin.tie(0)->sync_with_stdio(0);
  15.   cin >> n;
  16.   map<int,int> cnt;
  17.   for (int i = 1; i <= n; i++) {
  18.     cin >> a[i];
  19.     cnt[a[i]]++;
  20.   }
  21.   int ans = -1, mi = INT_MAX;
  22.   for (int i = 1; i <= n; i++) {
  23.     if (cnt[a[i]] == 1 && chmin(mi, a[i])) {
  24.       ans = i;
  25.     }
  26.   }
  27.   cout << ans << '\n';
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement