标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)
Total Submission(s): 339 Accepted Submission(s): 165
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int maxn = 200005; int a[maxn]; int prek[maxn]; int main() { int T;cin>>T; while(T--) { int n,m,k; cin>>n>>m>>k; memset(prek,0,sizeof(prek)); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); if(a[i]>=m) prek[i] += prek[i-1]+1; else prek[i] = prek[i-1]; } long long ans = 0; int sum = 0; int t = 1; for(int l=0;l<=n;l++) { while(t<=n&&sum<k) { sum = prek[t]-prek[l]; t++; } if(sum<k) break; ans += (n-t+2); sum = prek[t-1]-prek[l+1]; } printf("%I64d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/littlepear/p/5745200.html