Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define f first
- #define se second
- using namespace std;
- const long long int inf =(long long)1e18;
- const int dx[4] = {0, 0, 1, -1},dy[4] = {1, -1, 0, 0};
- typedef long long int ll;
- int main()
- {
- ROCK;
- int tc;
- cin>>tc;
- while(tc--)
- {
- int n,m,k,ans=0;
- cin>>n>>m>>k;
- k=min(k,m-1);
- int a[n+1];
- for(int i=1; i<=n; i++)cin>>a[i];
- for(int i=k+1,sub=0; i>=1; i--,sub++)
- {
- deque<int>dq;
- int turn=k+1;
- for(int j=i; j<=n-sub; j++)dq.push_back(a[j]);
- while(turn++<m)
- {
- if(dq.front()>dq.back())dq.pop_front();
- else dq.pop_back();
- }
- ans=max(ans,max(dq.front(),dq.back()));
- }
- cout<<ans<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement