fork download
  1. /*
  2. * @Author: hungeazy
  3. * @Date: 2026-03-04 23:24:15
  4. * @Last Modified by: hungeazy
  5. * @Last Modified time: 2026-03-12 19:59:53
  6. */
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. const int N = 1000010;
  10. int n,x;
  11. pair<int,int> a[N];
  12.  
  13. int main()
  14. {
  15. ios_base::sync_with_stdio(false);
  16. cin.tie(NULL); cout.tie(NULL);
  17. cin >> n >> x;
  18. for (int i = 1; i <= n; i++)
  19. {
  20. cin >> a[i].first;
  21. a[i].second = i;
  22. }
  23. sort(a+1,a+n+1);
  24. int l = 1, r = n, ans = -1;
  25. while (l <= r)
  26. {
  27. int mid = (l+r)>>1;
  28. if (a[mid].first < x) l = mid+1;
  29. else if (a[mid].first >= x)
  30. {
  31. ans = a[mid].second;
  32. r = mid-1;
  33. }
  34. }
  35. cout << ans;
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
-1