题意:给定长度为n的数列整数A0,A1,A2,A3....An-1,以及整数S,求出总和不小于S的连续子序列的长度的最小值。如果接不存在输出0。
解法:给出的整数都是正整数,所有以A(i+1)为左端点的合法区间右端点一定位于Ai为左端点的合法区间右端点的右侧(也有可能重合),这样就可以维护一个右端点指针进行追逐。
代码:
/****************************************************
* author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <string.h>
using namespace std;
#define eps 1e-8
typedef long long LL;
int n,S;
int num[100010];
int main()
{
int t;cin>>t;