[Codeforces] 279B - Books
来源:互联网 发布:蓝鸥unity3d 编辑:程序博客网 时间:2024/05/16 19:33
统计加二分查找。。
#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <algorithm>#include <iostream>#include <set>#include <map>#include <queue>#include <stack>using namespace std;int main(){ int n, t, a[100005], ans; while(~scanf("%d %d", &n, &t)) { a[0] = 0; ans = 0; for(int i = 1; i <= n; i++) { scanf("%d", &a[i]); a[i] += a[i-1]; } for(int i = 0; i < n; i++) { int left = i+1; int right = n; while(left <= right) { int mid = (left + right) / 2; if(a[mid] - a[i] <= t) { left = mid + 1; } else { right = mid - 1; } } ans = max(left - i, ans); } printf("%d\n", ans-1); } return 0;}
0 0
- Codeforces 279B Books
- codeforces 279 B. Books
- Codeforces 279B Books
- [Codeforces] 279B - Books
- Codeforces 279B books
- codeforces 279-B. Books(尺取)
- Codeforces 278B Books
- 【模拟】Books CodeForces 279B
- Codeforces 279B Books(dp大法好)
- CodeForces-552B - Vanya and Books
- CodeForces 552B-Vanya and Books
- 【33.33%】【codeforces 552B】Vanya and Books
- codeforces 552B Vanya and Books
- [CF 279B]Books[二分]
- Books CodeForces
- B. Books
- B. Vanya and Books(Codeforces Round #308 (Div. 2))
- CodeForces - 552B Vanya and Books (数学阶乘)水
- 制作.a静态库文件
- [poj1324]状态压缩+BFS
- 需求分析-用例图
- LeetCode-Validate Binary Search Tree
- 迅捷ppt转换器破解版下载
- [Codeforces] 279B - Books
- Swift研究之编程高级教程(二)属性,存储属性详解
- POJ 1006 Biorhythms 【中国剩余定理】
- linux cron实现计划任务
- MySQL大数据量分页SQL语句优化
- T0601——获取某一类的名称
- poj 1008
- python学习-多重继承
- C#位运算讲解与示例[转]