题意:给出n本书,总的时间t,每本书的阅读时间a[i],必须按照顺序来阅读,问最多能够阅读多少本书

有点像紫书的第七章讲的那个滑动区间貌似 维护一个区间的消耗的时间小于等于t,然后维护一个区间的最大值

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std; typedef long long LL;
const int INF = (<<)-;
const int mod=;
const int maxn=;
int a[maxn],pre[maxn]; int main(){
int n,t;
scanf("%d %d",&n,&t);
for(int i=;i<=n;i++) scanf("%d",&a[i]); pre[]=;
for(int i=;i<=n;i++) pre[i]=pre[i-]+a[i]; int l=;
int r=;
int sum=,ans=-;
while(r<=n){
if((pre[r]-pre[l])<=t){
ans=max(ans,r-l);
r++;
}
else l++;
}
printf("%d\n",ans);
return ;
}

Codeforces 279 B Books的更多相关文章

  1. CodeForces - 1214D B2. Books Exchange (hard version)

    题目链接:http://codeforces.com/problemset/problem/1249/B2 思路:用并查集模拟链表,把关系串联起来,如果成环,则满足题意.之后再用并查集合并一个链,一个 ...

  2. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  3. Codeforces Round #308 (Div. 2)B. Vanya and Books 数学

    B. Vanya and Books Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...

  4. CodeForces 279B Books

    http://codeforces.com/problemset/problem/279/B 题意 :Valera 有很多的空闲时间,所以他决定看书,给出n本书,编号1到n,和看每本书需要的时间,他看 ...

  5. CodeForces Round #515 Div.3 C. Books Queries

    http://codeforces.com/contest/1066/problem/C You have got a shelf and want to put some books on it. ...

  6. 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

    题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...

  7. 【33.33%】【codeforces 552B】Vanya and Books

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. B. Vanya and Books( Codeforces Round #308 (Div. 2) 简单题)

    B. Vanya and Books time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Codeforces Round #279 (Div. 2) vector

    A. Team Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

随机推荐

  1. Goolg Chrome 插件开发--Hello world

    开发Chrome插件很简单,只要会web开发(html+javascript+css)那么这个就是能驾轻就熟,只需要了解一下插件具体的运行环境及要求就OK了. 1.先创建一个html文件,名字随便取, ...

  2. Unix环境链接静态库

    静态库 请点评 有时候需要把一组代码编译成一个库,这个库在很多项目中都要用到,例如libc就是这样一个库,我们在不同的程序中都会用到libc中的库函数(例如printf),也会用到libc中的变量(例 ...

  3. (3)VS2010+Opencv-2.4.8的配置攻略

    这是windows平台上的东西,我为什么要写到安卓这一块呢 因为作者做的安卓方面的东西需要先在windows平台实现一下,所以就想写这篇东西,也参考了网上很多教程,不得不感叹,这些软件版本更新的太快. ...

  4. centOS学习part4:安装配置vsftp

    0 上一章(http://www.cnblogs.com/souvenir/p/3875934.html)我们完成了对远程工具VNC的安装配置,接下来我们将安装另外一个常用工具:VSFTP. vsft ...

  5. iOS开发--完整项目

    完整项目 Phonetic Swift 写的一个 iOS 版的 Phonetic Contacts,功能很多,其中昵称功能非常实用,已在 GitHub 开源并上架 App Store v2ex – v ...

  6. CreateProcess启动隐藏的外部程序(其实就是CreateDesktop,然后指定STARTUPINFO.lpDesktop)

    HDESK hDesk = CreateDesktop(_T("MyDesk"), NULL, NULL, 0, GENERIC_ALL, NULL); ASSERT(hDesk) ...

  7. Java:基本数据类型包装类

    基本数据类型对象包装类    基本数据类型(关键字)   引用数据类型(类)          byte                          Byte          short   ...

  8. SSIS -->> Variable

    变量的特点: 1)大小写敏感 2)可见范围限制,里层可以看到外层,外层看不到里层的: 在属性窗口开启EvaluateAsExpression选项可以支持expression动态赋值变量

  9. php mysql_insert_id()

    mysql_insert_id mysql_insert_id()返回给定的 link_identifier中上一步 INSERT 查询中产生的 AUTO_INCREMENT 的 ID 号.如果没有指 ...

  10. 给 Gradle 配置国内的 Maven 仓库,提高 jar 包下载速度。

    最近使用 gradle 跑一些 spring 的示例,在下载一些 jar 的时候速度特别慢,因为是访问的国外的 maven 仓库. 开源中国提供了国内的 maven 库,所以可以在 gradle 里设 ...