BZOJ1012: [JSOI2008] Maximum number of maxnumber

Source: Internet
Author: User

SB. 's question:

For some things ... I was completely degraded ...

1 //{HEADS2 #defineFile_in_out3 #defineDebug4#include <cstdio>5#include <cstring>6#include <cstdlib>7#include <cmath>8#include <ctime>9#include <algorithm>Ten#include <iostream> One#include <fstream> A#include <vector> -#include <stack> -#include <queue> the#include <deque> -#include <map> -#include <Set> -#include <bitset> +#include <complex> -#include <string> + #defineREP (i, j) for (int i = 1; I <= J; ++i) A #defineRepI (I, J, K) for (int i = j; I <= K; ++i) at #defineREPD (i, j) for (int i = j; 0 < i; i.) - #defineSTLR (I, con) for (int i = 0, Sz = con.size (); i < sz; ++i) - #defineStlrd (I, con) for (int i = Con.size ()-1; 0 <= i; i.) - #defineCLR (s) memset (s, 0, sizeof s) - #defineSET (S, v) memset (S, v, sizeof s) - #defineMP Make_pair in #definePB Push_back - #definePL (k, n) for (int i = 1; I <= n; ++i) {cout << k[i] << ";} cout << Endl to #definePS (k) STLR (I, k) {cout << k[i] << ";} cout << Endl + using namespacestd; - #ifdef Debug the #ifndef Online_judge *     Const intOut_put_debug_info =1; $ #endifPanax Notoginseng #endif - #ifdef Online_judge the     Const intOut_put_debug_info =0; + #endif A #defineDG if (out_put_debug_info) the voidFile_init (stringfile_name) { + #ifdef file_in_out - #ifndef Online_judge $Freopen ((file_name +". in"). C_STR (),"R", stdin); $Freopen ((file_name +". out"). C_STR (),"W", stdout); -  - #endif the #endif - }WuyitypedefLong LongLL; thetypedefDoubleDB; -typedef pair<int,int>I_pair; Wu Const intINF =0x3f3f3f3f; - //} About  $ Const intMAXN =200000+Ten; -  - intm, D; -  A structthings { +     intPos, Val; the things () {} -Things (intPosintval):p os (POS), Val (val) {} $     voidprint () { theprintf"%d%d\n", POS, Val); the     } the }S[MAXN]; the intTail =0; - /*{Get character*/ in CharGchar () { the     CharRET =GetChar (); the      for(; ret = ='\ n'|| RET = ='\ r'|| RET = =' '; RET =GetChar ()); About     returnret; the } the /*}*/ the  + intMain () { -File_init ("BZOJ1012"); the Bayiscanf"%d%d", &m, &d); the     CharOpe; the     intT, rec =0, cnt =0; - REP (i, m) { -Ope =Gchar (); thescanf"%d", &t); the         if(Ope = ='A') { theS[++tail] = Things (++cnt, (rec + t)%d); the DG s[tail].print (); -              for(;1< tail && S[tail-1].val <= S[tail].val; S[tail-1] = S[tail],--tail); the DG s[tail].print (); the}Else { the             intL =1, r =tail;94DG printf ("L =%d r =%d\n", L, R); the              while(L <r) { the                 intMid = (L + r) >>1; the                 if(Cnt-s[mid].pos +1<=t) {98R =mid; About}Else { -L = mid +1;101                 }102             }103REC =S[l].val;104printf"%d\n", rec); the         }106     }107 108     return 0;109}
View Code

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.