codeforces解题报告与总结
2013-03-05 19:25
363 查看
原题目点击打开链接
two pointer
#include<cstdio> #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<map> #include<vector> #include<cmath> using namespace std; int n,t; int a[100010]; bool cmp(int a,int b){ return a>b; } int main(){ while(cin>>n>>t){ for(int i=0;i<n;i++) cin>>a[i]; int T=0,ma=0; for(int k=0;k<n;k++){ if(T+a[k]>t) break; else{ T+=a[k]; ma++; } } //cout<<T<<ma<<endl; int max=ma; for(int i=1;i<n;i++){ T=T-a[i-1]; ma--; for(int j=i+ma;j<n;j++){ if(T+a[j]>t) break; else { T+=a[j]; ma++; } } if(max<ma) max=ma; } cout<<max<<endl; } }
相关文章推荐
- codeforces 344 B. Print Check解题报告
- 【解题报告】Codeforces Good Bye 2016
- 解题报告——直线整点数量问题总结
- NOIP2016复赛解题报告及考后总结
- codeforces A. Flipping Game 解题报告
- codeforces 2B 解题报告
- CodeForces 166E -Tetrahedron解题报告
- ZOJ3537 解题报告及总结
- CodeForces 240D D. Merging Two Decks 解题报告 贪心
- SSL Week 1 总结&解题报告
- codeforces 814B.An express train to reveries 解题报告
- CodeForces解题报告——4
- codeforces 140B.New Year Cards 解题报告
- BJFUOJ 1042解题报告(DFS回溯策略总结)
- SSL Week 3 总结&解题报告
- [置顶] hdu3018解题报告--也是白话几笔画学习总结
- 2018.1.30【 CodeForces - 612C 】解题报告(STL,栈,strlen使用注意)
- Codeforces 117C解题报告
- codeforces_240_div1解题报告
- [解题报告]Codeforces 105D Entertaining Geodetics