Codeforces B Greenhouse Effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.