Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- #define ld long double
- #define lFOR(i, a, b) for(ll i=(a); i<=(b); i++)
- #define lFORn(i, n) for(ll i=1; i<=(n); i++)
- #define lFORx(i, a, b, n) for(ll i=(a); i<=(b); i+=(x))
- #define FORa(i, b) for(i; i<=(b); i++)
- #define FORax(i, b, x) for(i; i<=(b); i+=(x))
- #define lFORR(i, a, b) for(ll i=(a); i>=(b); i--)
- #define lFORRn(i, n) for(ll i=(n); i>=1; i--)
- #define lFORRx(i, a, b, n) for(ll i=(a); i>=(b); i-=(x))
- #define FORRa(i, b) for(i; i>=(b); i--)
- #define FORRax(i, b, x) for(i; i>=(b); i-=(x))
- #define iFOR(i, a, b) for(int i=(a); i<=(b); i++)
- #define iFORn(i, n) for(int i=1; i<=(n); i++)
- #define iFORx(i, a, b, n) for(int i=(a); i<=(b); i+=(x))
- #define iFORR(i, a, b) for(int i=(a); i>=(b); i--)
- #define iFORRn(i, n) for(int i=(n); i>=1; i--)
- #define iFORRx(i, a, b, n) for(int i=(a); i>=(b); i-=(x))
- #define pb(x) push_back(x)
- #define all(x) (x).begin(), (x).end()
- #define sz(x) (x).size()
- #define sqr(x) (ll)(x)*(x)
- #define PI (2*acos(0))
- using namespace std;
- template <typename T>
- inline void Read(T& x)
- {
- bool Neg = false;
- char c;
- for (c = getchar(); c < '0' || c > '9'; c = getchar())
- if (c == '-') Neg = !Neg;
- x = c - '0';
- for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
- x = x * 10 + c - '0';
- if (Neg) x = -x;
- }
- template <typename T>
- inline void Write(T x)
- {
- if (x < 0)
- {
- putchar('-'); x = -x;
- }
- T p = 1;
- for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
- for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
- }
- //=================declare=================
- int t, n, k, p, res, inp;
- vector<int> a(102);
- //=================..end..=================
- //=================function=================
- //=================..end...=================
- int main(){
- freopen("solo.inp", "r", stdin);
- freopen("solo.out", "w", stdout);
- // ios_base::sync_with_stdio(0); cin.tie(0);
- //=================code=================
- Read(t);
- while(t--){
- Read(n);
- Read(k);
- Read(p);
- if(k&1){
- if(p==0){
- res=0;
- while(n--){
- cin>>inp;
- res=max(res, inp);
- }
- }
- else{
- res=1000000001;
- while(n--){
- cin>>inp;
- res=min(res, inp);
- }
- }
- }
- else{
- if(p==0){
- res=0;
- a[0]=a[n+1]=1000000001;
- iFORn(i, n){
- cin>>a[i];
- res=max(res, min(a[i-1], a[i+1]));
- }
- }
- else{
- res=1000000001;
- a[0]=a[n+1]=0;
- iFORn(i, n){
- cin>>a[i];
- res=min(res, max(a[i-1], a[i+1]));
- }
- }
- }
- Write(res);
- cout<<'\n';
- }
- //=================end.=================
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement