TOJ 2547 Subsequence

 1 /* 
 2  * File:   B.cpp
 3  * Author: GongZhi
 4  * Problem:
 5  * Created on 2009年7月27日, 上午9:07
 6  */
 7 
 8 #include <stdlib.h>
 9 #include <string.h>
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <queue>
15 using namespace std;
16 
17 /*
18  *
19  */
20 int a[110000];
21 
22 int main() {
23     int i, j,t,ans;
24     int n, s;
25     int kase;
26     scanf("%d",&kase);
27     while (kase--) {
28         scanf("%d%d"&n, &s);
29         ans=n+1;
30         for (i = 0; i < n; i++)scanf("%d"&a[i]);
31         i=0;j=0;t=0;
32         while(j<n){
33             t+=a[j++];
34             while(i<=&& t-a[i]>=s){
35                 t-=a[i];
36                 i++;
37             }
38             if(t>=&& j-i<ans)ans=j-i;
39         }
40         if(ans==n+1)printf("0\n");
41         else printf("%d\n",ans);
42     }
43     return 0;
44 }
45 

posted on 2009-07-27 15:52 gong 阅读(968) 评论(1)  编辑 收藏 引用

评论

# re: TOJ 2547 Subsequence 2009-07-28 15:21 彩铃

是大方科技是  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2009年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(6)

随笔档案

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜