HDOJ 5806 尺取法

哎 心塞的题目。

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cstdlib>
#include <ctime>
#include <time.h>

inline int Rand (){ return (rand () << 16) | rand ();}
//#define fi first
//#define se second
//#define mp make_pair
//#define sz(x) ( (int) (x).size ())
#define abs(x) ((x) < 0 ? -(x) : (x))
#define INF 20000000000000000ll
//#define sqr(x) ( (x) * (x))
//#define all(x) x.begin (), x.end ()
//#define files(x) freopen (x".in", "r", stdin); freopen (x".out", "w", stdout);
//#define MOD 1000000007
//#define y1 google
#define eps 1e-9
//#define tim ((clock() * 1.0) / CLOCKS_PER_SEC)
#define sf scanf
#define pf printf
#define fup(a,b) for(int i=a;i<=b;i++)
#define fdown(a,b) for(int i=a;i>=b;i--)
#define min(a,b) a>b?b:a
#define max(a,b) a>b?a:b
#define FP freopen("a.txt","r",stdin)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int maxn=200000+50;
ll a[maxn];
//set<ll>Save;
//map<ll,ll>Map;


int main()
{
	//FP;
	int t;
	sf("%d",&t);
	while(t--)
	{
		ll n,m,k;
		sf("%I64d%I64d%I64d",&n,&m,&k);
		fup(0,n-1)
		{
			sf("%I64d",&a[i]);
			if(a[i]>=m) a[i]=1;
			else a[i]=0;
		}
		ll sum,ans;
		ll low,high;
		ans=0;
		low=high=0;
		sum=a[0];
		while(low<=high&&high<n)
		{
			if(sum==k)
			{
				ans+=n-high;
				sum-=a[low++];
			}
			while(sum<k)  //if(sum<k)
			{
				sum+=a[++high];
			}
		}
		 
		cout<<ans<<endl;
	}
	return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值