标签:
1
7 4 2
4 2 7 7 6 5 1
18
题目大意: 
退役狗 NanoApe 滚回去学文化课啦!
在数学课上,NanoApe 心痒痒又玩起了数列。他在纸上随便写了一个长度为 
他想知道这个数列中有多少个区间里的第 
解题思路:
将不小于
时间复杂度
/**
2016 - 08 - 07 上午
Author: ITAK
Motto:
今日的我要超越昨日的我,明日的我要胜过今日的我,
以创作出更好的代码为目标,不断地超越自己。
**/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL INF = 1e9+5;
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const double eps = 1e-7;
const double PI = acos(-1);
using namespace std;
int a[MAXN], sum[MAXN];
inline bool cmp(LL a, LL b)
{
    return a > b;
}
int main()
{
    int T, n, m, k;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d%d",&n,&m,&k);
        memset(a, 0, sizeof(a));
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            if(x >= m)
                a[i] = 1;
        }
        int num = 0, r = 0;
        LL ans = 0;
        for(int i=1; i<=n; i++)
        {
            while(num<k && r<n)
            {
                r++;
                num += a[r];
            }
            if(num < k)
                break;
            ans += n-r+1;
            ///cout<<"ans = "<<ans<<endl;
            num -= a[i];
        }
        printf("%I64d\n",ans);
    }
    return 0;
}
HDU 5806 NanoApe Loves Sequence Ⅱ(尺取+思维)——BestCoder Round #86 1003
标签:
原文地址:http://blog.csdn.net/qingshui23/article/details/52141962