CodeForces - 1290A - Mind Control (thinking)

Topic links: https://vjudge.net/problem/CodeForces-1290A#author=zzuli_practice

Title effect: everyone can do an operation, take the number of columns in the first number or the second number, you can specify the number k of the individual away, you are the m

Personal, you can ask to get the minimum number is the largest number?

This question is a bit like the idea of ​​taking foot (similar to the operation vernier caliper it, but this time the fixed length of the cursor). First clear is the turn of the m-th election time

You can choose the number of columns of the first number, you can also choose the last one, because m-1 is fixed, so the rest of the series number is fixed, we put the rest of the

The number of columns called "Cursor", his range of movement it? If we specify k individuals have taken the final surface, then his extreme left is the first number, if we specify k individuals

Circumstances have taken the front, then he's far left is the number of k + 1, so his range of movement is 1-k + 1, we assume that the number of pre-k selected, and the rest of the requirements of randomly selected people

The maximum value of the minimum number of elected under the how to do it? In fact, we can get another a "cursor" because the election had already been a number of k, then the rest were randomly selected number (not their own) is mk-1 Ge

To the position of the first cursor position is 0, then the scope of the second cursor far left is 0 ~ mk-1, then the optimal strategy is to select the maximum number of cursor around the second end, and finally we only ask

The minimum value among the largest of these on the line

#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define endl '\n'
#define rtl rt<<1
#define rtr rt<<1|1
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define maxx(a, b) (a > b ? a : b)
#define minn(a, b) (a < b ? a : b)
#define zero(a) memset(a, 0, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define _test printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> P2;
const double pi = acos(-1.0);
const double eps = 1e-7;
const ll MOD =  1000000007LL;
const int INF = 0x3f3f3f3f;
const int _NAN = -0x3f3f3f3f;
const double EULC = 0.5772156649015328;
const int NIL = -1;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
const int maxn = 1e4+10;
int arr[maxn];
int main(void) {
    int t;
    scanf("%d", &t);
    while(t--) {
        zero(arr);
        int m, n, k;
        scanf(" % D% D% D " , & n-, & m, & K);
         for ( int I = 0 ; I <n-; ++ I) 
            Scanf ( " % D " , & ARR [I]);
         int ANS = - . 1 ;
         IF (K> = m) = K M- . 1 ; // the ideal case we just in front of the number m can be specified can be 
        for ( int I = 0 ; I <= K; ++ I) {
             int = TEMP INF;
             for ( int Z = 0 ; Z <= The MK- . 1 ; ++Z) 
                TEMP = min (TEMP, max (ARR [Z + I], ARR [Z + I + nm])); // + 1'd longitudinal length of the second interval after the cursor off the selected number m is n- i.e. . 1 + m 
            ANS = max (ANS, TEMP);                               // because the index is started from 0 nm of 
        } 
        the printf ( " % D \ n- " , ANS); 
    } 
    return  0 ; 
}

 

Guess you like

Origin www.cnblogs.com/shuitiangong/p/12426098.html
Recommended