zoukankan      html  css  js  c++  java
  • Codeforce -An impassioned circulation of affection

    尺取

    复杂度 (n)

     1 # include <cstdio>
     2 # include <iostream>
     3 # include <algorithm>
     4 # include <cstring>
     5 using namespace std;
     6 
     7 const int maxn=1500+5;
     8 int n,m;
     9 char s[maxn];
    10 int d;
    11 char ss[3];
    12 
    13 int main(){
    14   while(scanf("%d",&n)!=EOF){
    15     scanf("%s",s);
    16     scanf("%d",&m);
    17     while(m--){
    18         scanf("%d%s",&d,ss);
    19         int res=0,ls=0,rs=0,sum=0;
    20         for(ls=0;ls<n;ls++){
    21           while(rs<n&&sum+(s[rs]!=ss[0])<=d) {
    22             sum+=(s[rs]!=ss[0]);
    23             rs++;
    24           }
    25           res=max(res,rs-ls);
    26           sum-=(s[ls]!=ss[0]);
    27         }
    28     printf("%d
    ",res);
    29     }
    30   }
    31   return 0;
    32 }
    View Code
  • 相关阅读:
    第十五章:字段与属性
    第二十章:封装与继承
    第二十一章;泛型List
    第十九章:对象初始化器
    第十八章:构造方式
    第十七章:方法的重载
    request和response对象常用方法
    面向对象(1)
    request和response
    tomcat
  • 原文地址:https://www.cnblogs.com/lintanxi/p/6970476.html
Copyright © 2011-2022 走看看