标签:
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> using namespace std; const int INF = 9999990; int a[100001],dp[100001]; int mark[10000]; int ans[10000]; int k; int main() { #ifdef xxz freopen("in.txt","r",stdin); #endif // xxz int n,m; cin>>n>>m; for(int i = 0; i < n; i++) cin>>a[i]; for(int i = 0; i < n; i++){ memset(mark,0,sizeof(int)*n); mark[a[i]] = 1; ans[1]++; int Max = a[i], Min = a[i]; for(int j = i+1; j < n; j++){ if(mark[a[j]]++) break; Max = max(Max,a[j]); Min = min(Min,a[j]); if(Max - Min == j - i) ans[j-i+1]++; } } cout<<"Case #1:"<<endl; for(int i = 1; i <= m; i++){ cin>>k; cout<<ans[k]<<endl; } return 0; }
标签:
原文地址:http://blog.csdn.net/u013445530/article/details/46430971