jakaria_hossain

codeforce - city day

Aug 4th, 2019
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,a,b;
  6. cin>>n>>a>>b;
  7. int ara[n+1];
  8. for(int i=0; i<n; i++)
  9. cin>>ara[i];
  10. int i,x=0,y=min(a,n-1);
  11. bool f=true;
  12. if(b==0)
  13. {
  14.  
  15. cout<<1<<endl;
  16.  
  17. }
  18. else
  19. {
  20. //cout<<y<<endl;
  21. for(i=0; i<y; i++)
  22. {
  23. if(ara[i]<ara[i+1])
  24. {
  25. x=i;
  26. f=false;
  27. break;
  28. }
  29. else if(ara[i]<ara[y])
  30. {
  31. x=i;
  32. f=false;
  33. break;
  34. }
  35.  
  36. }
  37. if(f)
  38. x=y;
  39.  
  40. for(i=x+1; i<min(x+b+1,n); i++)
  41. {
  42. if(ara[i]<ara[x])
  43. {
  44. x=i;
  45. }
  46. }
  47. cout<<x+1<<endl;
  48.  
  49.  
  50. }
  51.  
  52. }
RAW Paste Data