Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  3. #define f first
  4. #define se second
  5. using namespace std;
  6. const long long int inf =(long long)1e18;
  7. const int dx[4] = {0, 0, 1, -1},dy[4] = {1, -1, 0, 0};
  8. typedef long long int ll;
  9. int main()
  10. {
  11. ROCK;
  12. int tc;
  13. cin>>tc;
  14. while(tc--)
  15. {
  16. int n,m,k,ans=0;
  17. cin>>n>>m>>k;
  18. k=min(k,m-1);
  19. int a[n+1];
  20. for(int i=1; i<=n; i++)cin>>a[i];
  21. for(int i=k+1,sub=0; i>=1; i--,sub++)
  22. {
  23. deque<int>dq;
  24. int turn=k+1;
  25. for(int j=i; j<=n-sub; j++)dq.push_back(a[j]);
  26. while(turn++<m)
  27. {
  28. if(dq.front()>dq.back())dq.pop_front();
  29. else dq.pop_back();
  30. }
  31. ans=max(ans,max(dq.front(),dq.back()));
  32. }
  33. cout<<ans<<endl;
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement