Codeforces 526E Transmitting Levels
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的更多相关文章
- CodeForces ZeptoLab Code Rush 2015
拖了好久的题解,想想还是补一下吧. A. King of Thieves 直接枚举起点和5个点之间的间距,进行判断即可. #include <bits/stdc++.h> using na ...
- 【奶昔队ROUND#1】
奶昔队Round #1 热身 (奶昔队不是真正的队,是群) CodeForces 435C Cardiogram 模拟,不过我做的时候不是模拟,是计算...(写了好久,还wa了几次),现在看了别人的代 ...
- Codeforces 643C Levels and Regions 斜率优化dp
Levels and Regions 把dp方程列出来, 把所有东西拆成前缀的形式, 就能看出可以斜率优化啦. #include<bits/stdc++.h> #define LL lon ...
- 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 ...
- Codeforces Round #354 (Div. 2)-B
B. Pyramid of Glasses 题目链接:http://codeforces.com/contest/676/problem/B Mary has just graduated from ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 源代码管理(Windows + VisualSVN Server + TortoiseSVN + VS2010)
之前项目中使用过SVN管理源代码,但是都是链接别人搭建的服务器,现在感觉每周保留一个版本蛮麻烦的,就搭建一个,方便以后管理代码. 1.安装VisualSVN Server( VisualSVN Ser ...
- Delphi 调试BPL包中引用另外的BPL的方法。
在实际程序中,遇到1.bpl 引用了2.bpl中的方法,2.bpl的方法进入后又引用了3.bpl ,刚开始挺蒙,怎么调试呢, 其实bpl就是dll, 故, 1.我在Delphi的run->pa ...
- 多个ajax按照顺序执行的方法
$.ajax({ dataType: "json", async: false, //只需将此属性设置为false url: ~~, type: "GET", ...
- HDU_2015——偶数求和
Problem Description 有一个长度为n(n<=100)的数列,该数列定义为从2开始的递增有序偶数,现在要求你按照顺序每m个数求出一个平均值,如果最后不足m个,则以实际数量求平均值 ...
- [React Testing] Conditional className with Shallow Rendering
Often our components have output that shows differently depending on the props it is given; in this ...
- oracle group by rollup,decode,grouping,nvl,nvl2,nullif,grouping_id,group_id,grouping sets,RATIO_TO
干oracle 047文章12当问题,经验group by 声明.因此邂逅group by rollup,decode,grouping,nvl,nvl2,nullif,RATIO_TO_REPOR ...
- Swift补基础之Selector、条件编译、编译标记、NSObject
在swift中使用条件编译比较直接 #if <condition> #elseif <condition> #else #endif 例如 :在debug模式和release模 ...
- mysql 建立加密连接
加密连接可提高数据的安全性,但会降低性能.要进行加密连接,必须满足以下要求: user权限表里要有相关的SSL数据列.如果安装的MySQL服务器是4.0.0版的,user权限表已包含相关的SSL数据列 ...
- 忽略git中不需要进行版本管理的文件
在git中我们提交项目的时候有很多东西是不需要进行版本管理的,因此我们需要忽略掉. 虽然在github2.0的windows客户端提供了工具,但是这个工具并不是想象中的那么好用. 在上面点右键出现的D ...
- FeatureClass的"import"(转换)功能
/// <summary> /// FeatureClass的"import"功能. /// </summary> /// <param name=& ...