• 【BZOJ 1012】 [JSOI2008]最大数maxnumber


    以前看过这个题 这次一遍A 真舒服

    留下最大值 每次二分就行

    #include <cstdio>
    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #define LL long long
    using namespace std;
    LL a[200000+1],b[200000+1];
    LL n,MO;
    LL tot=1;
    int main()
    {
    //	fre0open("a.in","r",stdin);
    	cin>>n>>MO;LL tmp=0;
    	int cnt=0;
    	for(int i=1;i<=n;i++)
    	{
    		char c;getchar();c=getchar();
    		if(c=='A')
    		{
    			LL x;scanf("%lld",&x);x+=tmp;x%=MO;
    			while(a[tot]<=x&&tot>0) tot--;
    			a[++tot]=x;
    			b[tot]=++cnt;
    		}
    		else 
    		{
    			LL x;scanf("%d",&x);
    			x=cnt-x+1;//cout<<a[1]<<' '<<a[2]<<endl;
    			int L=1,R=tot; 
    			while(L<R)
    			{
    				int mid=(L+R)/2;
    				if(b[mid]<x) L=mid+1;
    				else R=mid;
    			}
    			tmp=a[L];
    			printf("%lld
    ",tmp);
    		}
    		
    	}
    	
    	return 0;
    }
    
  • 相关阅读:
    day32-python阶段性复习六
    golang 项目中坑
    golang crawler
    router
    golang in ubuntu
    go channel 案例分析
    go channel learning
    bee go + mgo
    URL escape and unescape
    [转]good sample of Go
  • 原文地址:https://www.cnblogs.com/ofsxb/p/5116842.html
Copyright © 2020-2023  润新知