标签:
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 5342 | Accepted: 3184 |
Description
1 5 3 2 5 1 3 4 4 2 5 1 2 3
Input
Output
Sample Input
14 5 1 5 3 2 5 1 3 4 4 2 5 1 2 3
Sample Output
3
Hint
Source
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
int n,k;
bool vis[10010];
int main()
{
int ans=0,cnt=0,x;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
if(!vis[x])
{
vis[x]=1;
cnt++;
}
if(cnt==k)
{
memset(vis,0,sizeof(vis));
cnt=0;
ans++;
}
}
printf("%d\n",ans+1);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4430180.html