Advertisement
Saleh127

cf 1433C

Oct 21st, 2020
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll a[300005];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);cout.tie(0);
  10.  
  11. test
  12. {
  13. ll c,d,e,f,i,j,k=-1,l=0;
  14.  
  15. cin>>c;
  16. for(i=1;i<=c;i++)
  17. {
  18. cin>>a[i];
  19. l=max(l,a[i]);
  20. }
  21. for(i=1;i<=c;i++)
  22. {
  23. if(a[i]==l && i==1)
  24. {
  25. if(a[i+1]<l)
  26. {
  27. k=i;
  28. }
  29. }
  30. else if(a[i]==l && i==c)
  31. {
  32. if(a[i-1]<l)
  33. {
  34. k=i;
  35. }
  36. }
  37. else if(a[i]==l && (a[i-1]<l || a[i+1]<l))
  38. {
  39. k=i;
  40. break;
  41. }
  42. }
  43. cout<<k<<endl;
  44. }
  45.  
  46.  
  47. return 0;
  48. }
  49.  
Advertisement
RAW Paste Data Copied
Advertisement