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 ...
随机推荐
- Linux系统编程(35)—— socket编程之TCP服务器的并发处理
我们知道,服务器通常是要同时服务多个客户端的,如果我们运行上一篇实现的server和client之后,再开一个终端运行client试试,新的client就不能能得到服务了.因为服务器之支持一个连接. ...
- redis 异常排查
异常排查 redis-server redis.windows.conf D:\redis-2.8.17>redis-server.exe redis.windows.conf[4692] 27 ...
- Missing Ranges 解答
Question Given a sorted integer array where the range of elements are in the inclusive range [lower, ...
- SQL-Employees Earning More Than Their Managers
思路: 今天复习数据库突然想起来leetcode上数据库的题目,就找来做了 (1)给表取别名 格式见code,这在自身连接的时候是很有必要的 (2)自身连接 from语句后面相当于接了“一张表”,如果 ...
- Wish | IT桔子
Wish | IT桔子 Wish www.wish.com 认领 关注 分享
- iOS- UITableView could not hold the selected row after reload
I like stackoverflow.. Answer : http://stackoverflow.com/questions/6649202/uitableview-doesnt-keep-r ...
- Java继承与清理
[程序实例] import java.util.*; class Characteristic { private String s; Characteristic(String s) { this. ...
- iOS--九宫格布局
[self rankWithTotalColumns: andWithAppW: andWithAppH:]; //九宫格布局 - (void)rankWithTotalColumns:(int)to ...
- webpack之基础学习
webpack工作原理: 通过一个入口文件,main.js开始找到你的项目的所有依赖文件,使用loaders处理它们,最后打包为一个浏览器可识别的JavaScript文件. Webpack的核心原理 ...
- JavaScript 去除数组重复成员
[...new Set(array)] 运用 Set结构不会添加重复的值 和...解构 function dedupe(array) { return Array.from(new Set(array ...