[尺取法] poj 3061 Subsequence
来源:互联网 发布:b2b营销软件 编辑:程序博客网 时间:2024/05/07 04:17
题目分析
尺取法裸题。尺取法详解题目见尺取法题目
代码
#include <cstdio>#include<iostream>#include<cmath>#include<cstring>#include<string>#include<algorithm>#include<map>using namespace std;const int maxn=1e5+5;long long a[maxn];int main(){ int T; cin>>T; while(T--) { int n,s; cin>>n>>s; int ans=2*n; for(int i=0;i<n;i++) scanf("%d",&a[i]); int l=0,r; long long sum=0; for(r=0;r<n;r++) { sum+=a[r]; if(sum<s) continue; while(l<r && sum-a[l]>=s) sum-=a[l],l++; ans=min(ans,r-l+1); } if(ans>n) ans=0; cout<<ans<<endl; } return 0;}
0 0
- poj 3061--Subsequence(尺取法)
- poj 3061 Subsequence(尺取法)
- POJ 3061 Subsequence ( 尺取法 )
- POJ 3061 Subsequence(尺取法)
- Poj 3061 Subsequence【尺取法】
- poj 3061 Subsequence (尺取法)
- POJ 3061 Subsequence【尺取法】
- POJ 3061 Subsequence【尺取法】
- 尺取法 POJ 3061 Subsequence
- 【尺取法】poj 3061 Subsequence
- [尺取法] poj 3061 Subsequence
- poj 3061 Subsequence尺取法
- POJ 3061 Subsequence 尺取法
- POJ 3061 Subsequence 【尺取法】
- Poj 3061 Subsequence【尺取法】
- 【poj】 3061 Subsequence 尺取法
- POJ 3061 Subsequence 尺取法
- POJ 3061 - Subsequence(尺取法)
- 线程安全和线程同步Synchronized
- c++ 在windwos上创建盘符,并且,监控盘符里面任一文件的变动事件
- RecyclerView has no adapter, skip layout
- android-----我眼中的Binder
- javascript针对DOM的应用(一)
- [尺取法] poj 3061 Subsequence
- HDU-5363 Key Set 【快速幂取模+递推】
- factory model
- cocos2dx.3.x之重要类分析(4)——Layer
- JDK自定义安装路径(安装与环境变配置)[Java可以javac不行的原因及正确的安装方法]
- 读github上的爬虫代码(html_downloader)
- 2016年上半年总结(大二上学期学期总结)
- leetcode_c++:栈:Implement Queue using Stacks(232)
- 125. Valid Palindrome