http://codeforces.com/contest/526/problem/E

题意:给一个环,每个点有权值,每次给一个数B,求把这个环切割成若干部分,每个部分不超过B,至少要切成几块?

#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
ll a[];
int g[],f[];
int n,m;
ll read(){
ll t=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
n=read();m=read();
for (int i=;i<=n;i++)
a[i]=read(),a[i+n]=a[i];
for (int i=;i<=*n;i++)
a[i]+=a[i-];
while (m--){
for (int i=;i<=*n;i++)
g[i]=i,f[i]=;
ll T=read();
int j=,ans=0x7fffffff;
for (int i=n+;i<=*n;i++){
while (j<=i&&a[i]-a[j-]>T) j++;
f[i]=f[j-]+;
g[i]=g[j-];
if (i-g[i]>=n) ans=std::min(ans,f[i]);
}
printf("%d\n",ans);
}
return ;
}

Codeforces 526E Transmitting Levels的更多相关文章

  1. CodeForces ZeptoLab Code Rush 2015

    拖了好久的题解,想想还是补一下吧. A. King of Thieves 直接枚举起点和5个点之间的间距,进行判断即可. #include <bits/stdc++.h> using na ...

  2. 【奶昔队ROUND#1】

    奶昔队Round #1 热身 (奶昔队不是真正的队,是群) CodeForces 435C Cardiogram 模拟,不过我做的时候不是模拟,是计算...(写了好久,还wa了几次),现在看了别人的代 ...

  3. Codeforces 643C Levels and Regions 斜率优化dp

    Levels and Regions 把dp方程列出来, 把所有东西拆成前缀的形式, 就能看出可以斜率优化啦. #include<bits/stdc++.h> #define LL lon ...

  4. CodeForces 674C Levels and Regions

    #include<bits/stdc++.h> using namespace std; const int maxn=2e5+5; int N,K,head,tair; int q[ma ...

  5. Codeforces Round #354 (Div. 2)-B

    B. Pyramid of Glasses 题目链接:http://codeforces.com/contest/676/problem/B Mary has just graduated from ...

  6. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分

    C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is p ...

  7. Codeforces Beta Round #6 (Div. 2 Only) D. Lizards and Basements 2 dp

    题目链接: http://codeforces.com/problemset/problem/6/D D. Lizards and Basements 2 time limit per test2 s ...

  8. Codeforces Round #290 (Div. 2) B. Fox And Two Dots dfs

    B. Fox And Two Dots 题目连接: http://codeforces.com/contest/510/problem/B Description Fox Ciel is playin ...

  9. Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))

    C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

随机推荐

  1. BZOJ3392: [Usaco2005 Feb]Part Acquisition 交易

    3392: [Usaco2005 Feb]Part Acquisition 交易 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 26  Solved:  ...

  2. 【转】ActionBar的基本用法

    原文网址:http://irtutsk.iteye.com/blog/2117707 ActionBar的组成: [1]AppIcon:标题区,显示应用程序图标和标题,也可以自定义. [2]ViewC ...

  3. HDU_2041——走楼梯,递推

    Problem Description 有一楼梯共M级,刚开始时你在第一级,若每次只能跨上一级或二级,要走上第M级,共有多少种走法?   Input 输入数据首先包含一个整数N,表示测试实例的个数,然 ...

  4. CF#345 div2 A\B\C题

    A题: 贪心水题,注意1,1这组数据,坑了不少人 #include <iostream> #include <cstring> using namespace std; int ...

  5. double精度的坑与BigDecimal

    近期经常接触支付相关的功能,在开发及测试过程中,开始金额都使用的是double类型,而近期新进的需求存在支付时打折的情况,也就是会出现如 1.23元的情况,那么这时候问题来了,如果是直接使用1.23进 ...

  6. Oracle_Q&A_01

    Step01: SHOW USER DESCRIPTION Step02:QUESTION & ANSWER --查询员工姓名和职位字数相等的员工 SELECT * from emp wher ...

  7. memcached几个easy被忽略但很实用的命令

    一.CAS和GETS Memcached从1.2.4版本号新增CAS(Check and Set)协议,用于处理同一个ITEM(key-value)被多个session更新改动时的数据一致性问题. 如 ...

  8. C++ primer 中文第三版 阅读笔记 第八章

    一.寄存器对象: 函数中频繁被使用的变量可以加上register就可声明为寄存器对象.对于寄存器对象,假如能够放到寄存器中就会放到寄存器中,放不到的话就放到内存中.比如 register int  a ...

  9. BFC——块级格式上下文

    BFC中的B指的是block,对应的还有IFC,I指的是inline.对于BFC的理解可以参考层叠上下文.页面中,盒子的排布规则,是生效在对应的BFC中.两个BFC中的布局互不影响.页面的本身的根本身 ...

  10. java语句与流程控制

    java程序结构按照结构化程序的思想分为顺序结构,选择结构,和循环结构. ①选择语句 选择结构分为单选择,双选择和多选择.双选择是标准的选择结构,单选择是双选择的简化形式,多选择是双选择的嵌套形式. ...