B - Pyramid of Glasses

n层杯子,问k分钟能流满多少个杯子?和到香槟一样的过程?

思路:应为水的流速为每分钟一立方体(YY),可以做个转化,把最上层的杯子最原始的容积看成K,每个杯子的满的状态为体积为1,那么只要判断所有杯子体积是否大于1就可以。

 //#pragma comment(linker, "/STACK:167772160")//手动扩栈~~~~hdu 用c++交
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
// #include<malloc.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
typedef long long LL;
const int inf = 0x3f3f3f3f;
const double eps = 1e-;
const double pi = acos(-);
const LL MOD = 1e9+;
// const LL p = 1e9+7;
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
double v[][]; int main(){
int n;
double t;
scanf("%d%lf",&n,&t);
clc(v,0.0);
v[][]=t;
int ans=;
for(int i=;i<=n;i++){
for(int j=;j<=i;j++){
if(v[i][j]>=){
v[i+][j]+=(v[i][j]-)/;
v[i+][j+]+=(v[i][j]-)/;
ans++;
}
}
}
printf("%d\n",ans);
return ;
}

C - Vasya and String

有一个长度为n的字符串,你可以改变最多k次,问你最长的全是一样字符的串是多长,这个字符串只含有a和b字符

两种解法:都要设置两个指针枚举符合的区间长度

1:首先改变的字符一定要“相邻”,枚举改变了的个数,保持枚举的区间范围内都含有k个改变值

 //#pragma comment(linker, "/STACK:167772160")//手动扩栈~~~~hdu 用c++交
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
// #include<malloc.h>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define LL long long
const int inf = 0x3f3f3f3f;
const double eps = 1e-;
const double pi = acos(-);
const LL MOD = 1e9+;
// const LL p = 1e9+7;
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
int n,k;
char s[];
int work(char c){
int l,len;
int ans;
ans=;
l=len=;
for(int r=;r<n;r++){
if(s[r]==c)
len++;
while(len>k){
if(s[l]==c)
len--;
l++;
}
ans=max(ans,r-l+);
}
return ans;
} int main(){ scanf("%d%d",&n,&k);
cin>>s;
int ans1=work('a');
int ans2=work('b');
printf("%d\n",max(ans1,ans2));
return ;
}

2:预处理前缀和,再二分区间长度

codeforces 354 DIV2的更多相关文章

  1. codeforces 354 div2 C Vasya and String 前缀和

    C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  3. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  4. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  5. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  6. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  7. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  8. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  9. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

随机推荐

  1. Unity3d + NGUI 的多分辨率适配(黑边)

    原地址:http://www.2cto.com/kf/201310/250921.html 一.当下移动设备的主流分辨率(数据来自“腾讯分析移动设备屏幕分辨率分析报告”) 1.1 iOS设备的分辨率主 ...

  2. stl map高效遍历删除的方法

    for(:iter!=mapStudent.end():) {      if((iter->second)>=aa)      {          //满足删除条件,删除当前结点,并指 ...

  3. 【leetcode】Divide Two Integers (middle)☆

    Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...

  4. DP的简单应用

    Problem A:简单的图形覆盖 Time Limit:1000MS  Memory Limit:65536KTotal Submit:201 Accepted:104 Description 有一 ...

  5. hdu 2028 Lowest Common Multiple Plus(最小公倍数)

    Lowest Common Multiple Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  6. Java泛型:泛型类、泛型接口和泛型方法

    根据<Java编程思想 (第4版)>中的描述,泛型出现的动机在于: 有许多原因促成了泛型的出现,而最引人注意的一个原因,就是为了创建容器类. 泛型类 容器类应该算得上最具重用性的类库之一. ...

  7. Qt: 读写二进制文件(写对象, 原始数据等)

    #include <iostream>#include <QFile>#include <QImage>#include <QMap>#include ...

  8. Source Insight 安装使用

    习惯了在source insight下编辑阅读源码,在linux下用vi总是用不好 ,还是在Ubuntu上用回熟悉的source insight. 在Ubuntu中,安装Windows程序用wine, ...

  9. python学习笔记八--动态类型

    一.变量,对象,引用: 1. 变量: 2. 对象:均包含了一个头部信息,有以下两部分内容 a.对象的数据类型, b.引用计数器:纪录当前引用货指向该对象的数量,一旦计数器被清零,该对象的内存空间就会被 ...

  10. 查看32bit的ARM(比如ARMv7)反汇编

    1.使用./arm-eabi-as test.S -o test.o编译 2.使用./arm-eabi-objdump -d test.o反汇编