Test instructions: give you a sequence that asks you at least how many numbers to move so that the sequence does not decrement.
Problem solving idea: actually is to find this sequence of the longest non-descending subsequence.
Problem Solving Code:
1 //File name:269b.cpp2 //Author:darkdream3 //Created time:2015 March 09 Monday 18:44 02 Seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long - - using namespacestd; - inta[10000]; - intans[10000]; in intN, M; - intFind (intLintRintx) to { + while(L <=R) - { the intm = (L + r)/2; * if(Ans[m] <=x) $ {Panax NotoginsengL = m +1; -}Else { ther = M-1; + } A } the returnl; + } - intSolve () $ { $ intt =1; -ans[1] = a[1]; - for(inti =2; I <= N;i + +) the { - if(A[i] >=Ans[t])Wuyi { theT + + ; -ANS[T] =A[i]; Wu}Else{ - //printf ("%d%d\n", I,find (1,t,a[i])); AboutAns[find (1, T,a[i])] =A[i]; $ } - /*for (int i = 1;i <= t;i + +) - printf ("%d", ans[i]); - printf ("\ n");*/ A } + returnN-T; the } - intMain () { $scanf"%d%d",&n,&m); the Doubletmp; the for(inti =1; I <= N;i + +) the { thescanf"%d%lf",&a[i],&tmp); - } inprintf"%d\n", Solve ()); the return 0; the}
View Code
Codeforces B Greenhouse Effect