本來想說是用二分法,不過沒有二分的那種關係,而且測資滿小的直接掃過去就好了
/*
* GCA : "Computer is artificial subject absolutely,Math is God"
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cctype>
#include <utility>
#include <ctime>
using namespace std;
#ifdef DEBUG
#define VAR(a,b) __typeof(b) a=(b)
#define debug(...) printf("DEBUG: "),printf(__VA_ARGS__)
#else
#define VAR(a,b) decltype(b) a=(b)
#define debug(...)
#endif
typedef unsigned int uint;
typedef long long int Int;
typedef unsigned long long int UInt;
#define Set(a,s) memset(a,s,sizeof(a))
#define Pln() printf("\n")
#define For(i,x)for(int i=0;i<x;i++)
#define CON(x,y) x##y
#define M ${MAX_LIMITS}
#define PB push_back
#define oo INT_MAX
#define FOR(a,b) for(VAR(a,(b).begin());a!=(b).end();++a)
#define eps 1e-9
#define X first
#define Y second
inline bool xdy(double x,double y){return x>y+eps;}
inline bool xddy(double x,double y){return x>y-eps;}
inline bool xcy(double x,double y){return x<y-eps;}
inline bool xcdy(double x,double y){return x<y+eps;}
const Int mod=1000000007;
class ClapLight {
bool check(vector<int> v,int t){
for(int i=0;i<v.size()-3;i++){
if(v[i]<t&&v[i+1]>=t&&v[i+2]>=t&&v[i+3]<t){
return false;
}
}
return true;
}
public: int threshold(vector<int> background) {
vector<int> sor=background;
sort(sor.begin(),sor.end());
int cen=(sor.size())/2;
int from=sor[cen]+1;
int to=sor[sor.size()-1]+1;
if(from>to)to=from;
for(int i=from;i<=to;i++){
if(check(background,i)){
return i;
}
}
return -1;
}
};
留言
張貼留言