博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj——3061Subsequence(尺取法 求最小数量满足S)
阅读量:4049 次
发布时间:2019-05-25

本文共 1234 字,大约阅读时间需要 4 分钟。

Subsequence
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 12317   Accepted: 5171

Description

A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S < 100 000 000) are given. Write a program to find the minimal length of the subsequence of consecutive elements of the sequence, the sum of which is greater than or equal to S.

Input

The first line is the number of test cases. For each test case the program has to read the numbers N and S, separated by an interval, from the first line. The numbers of the sequence are given in the second line of the test case, separated by intervals. The input will finish with the end of file.

Output

For each the case the program has to print the result on separate line of the output file.if no answer, print 0.

Sample Input

210 155 1 3 5 10 7 4 9 2 85 111 2 3 4 5

Sample Output

23

Source

#include
#include
#include
#include
#include
#include
using namespace std;int n,m;int a[100010];void solve(){ int sum=0; int k,p,q; k=q=0; p=n+1; for(;;) { while(k
>t; while(t--) { cin>>n>>m; memset(a,0,sizeof(a)); for(int i=0;i
>a[i]; solve(); } return 0;}

转载地址:http://axfci.baihongyu.com/

你可能感兴趣的文章
开发中的Warning原来也很有用
查看>>
Silverlight Toolkit例子代码中缺少System.Windows.Controls.Samples.Common.dll的解决办法
查看>>
项目经理培训后的一点感概
查看>>
vc学习之窗口大小发生变更时使控件自动摆放到合适的位置
查看>>
Oracle 获取系统日期时间,导出数据库
查看>>
黄巢的菊花,非常喜欢,贴出来共享一下
查看>>
在光纤环网中的b/s与c/s的比对
查看>>
根据程序名称和程序路径判断程序是否启动
查看>>
史记翻译-汉初三杰-萧何-萧相国世家第二十三
查看>>
史记翻译-汉初三杰-张良-留侯世家第二十五
查看>>
史记翻译-汉初三杰-韩信-淮阴侯列传第三十二
查看>>
帝王封赏之道和老板的封赏之道
查看>>
工作分解结构在软件开发中的应用
查看>>
关于系统崩溃后的Oracle恢复
查看>>
遭遇蚊子的獠牙,想起一种叫黄鸡婆的小虫子
查看>>
使用批处理命令给客户更新oracle数据库
查看>>
回首考研路:那年,那月,还有那条孤独的考研狗
查看>>
GCD小结
查看>>
IOS 第三方库介绍
查看>>
iPhone架构xmpp聊天工具 -xmpp协议初识《一》
查看>>