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下重启指定名称的服务
// 重启指定服务 void CPSSDPrinterCtrlPlug::RestartService(const wchar_t* nswServiceName) { SC_HANDLE schSC ...
- 扩展Visual Studio IDE
安装visual studio 2012 SDK 下载visual studio SDK. 安装可能遇到的问题 安装时报错:Visual Studio 2012 Install Fails: Prog ...
- MYSQL触发器学习笔记
课程学至金色晨曦科技公司技术总监沙利穆 触发器 1. 什么是触发器 触发器是一种特殊类型的存储过程,不由用户直接调用.创建触发器时会对其进行定义,以便在对特定表或列作特定类型的数据修改时执 ...
- 继承PictureBox显示GIF的自定义控件实现
处理GIF部分 using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...
- SurfaceView类透明背景设置
将SurfaceView背景设置为透明,主要添加以下几句话就可以了: 在SurfaceView创建后设置一下下面的参数: setZOrderOnTop(true); getHolder().setFo ...
- DS18B20
DS18B20驱动 [ 2012-5-14 12:01:00 | By: 吴师傅 ] 14 推荐 一.概述 DS18B20是一种单总线数字温度传感器.測试温度范围-55℃-125℃,温度数据位可配 ...
- [iOS]使用symbolicatecrash分析crash文件
对于我们iOS开发者来说,最心碎的事莫过于苹果审核一个星期后上架app store,而第二天就报出闪退bug.一周前我刚经历过,而且最坑的是由于第一次做个人开发,经验不足,没有集成友盟的分析SDK,还 ...
- Java static块
首先,我们看一个实际例子: class Test{ public static int X=100; public final static int Y=200; public Test(){ Sys ...
- linux内存机制
~# free -m total used free shared buffers cachedMem: 16086 8579 7507 0 152 800 ...
- 路由器密码破解工具 Hydra 7.5
之前只在 Browser 中保存了路由管理密码,无奈升级时管理的密码丢失了,又不想重新设置,所以尝试破解登录密码. 使用破解工具 Hydra 7.5. # hydra -l username -x : ...