fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int N=1e6+4;
  4. long long a[N],n,x;
  5. int yc1()
  6. {
  7. for(int i=0;i<n;i++)
  8. {
  9. if(a[i]==x) return i;
  10. }
  11. return -1;
  12. }
  13. int yc2()
  14. {
  15. long long kq=-1;
  16. for(int i=0;i<n;i++)
  17. {
  18. if(a[i]==x) kq=i;
  19. }
  20. return kq;
  21. }
  22. int yc3()
  23. {
  24. for(int i=0;i<n;i++)
  25. {
  26. if(a[i]>=x) return i;
  27. }
  28. return -1;
  29. }
  30. int yc4()
  31. {
  32. for(int i=0;i<n;i++)
  33. {
  34. if(a[i]>x) return i;
  35. }
  36. return -1;
  37. }
  38. map<long long,long long>mp;
  39. int main()
  40. {
  41. cin>>n>>x;
  42. for(int i=0;i<n;i++)
  43. {
  44. cin>>a[i];
  45. mp[a[i]]++;
  46. }
  47. cout<<yc1()<<endl;
  48. cout<<yc2()<<endl;
  49. cout<<yc3()<<endl;
  50. cout<<yc4()<<endl;
  51. cout<<mp[x]<<endl;
  52.  
  53.  
  54. }
  55.  
Success #stdin #stdout 0.01s 5540KB
stdin
Standard input is empty
stdout
-1
-1
-1
-1
0