hdu 5210 Delete

来源:互联网 发布:什么是网络存储 编辑:程序博客网 时间:2024/06/03 11:09

WLD likes playing with numbers. One day he is playing with NN integers. He wants to delete KK integers from them. He likes diversity, so he wants to keep the kinds of different integers as many as possible after the deletion. But he is busy pushing, can you help him?
Input
There are Multiple Cases. (At MOST 100100)

For each case:

The first line contains one integer N(0

#include<stdio.h>#include<algorithm>using namespace std;int main(){    int n;    while(~scanf("%d",&n))    {        int a[10003];        for(int i=0;i<n;i++)scanf("%d",&a[i]);        sort(a,a+n);        int ans=0;        for(int i=0;i<n-1;i++)            if(a[i]==a[i+1])ans++;        int k=0;        scanf("%d",&k);        int sum=n-ans;        k-=ans;        if(k>0)            sum-=k;        else sum=sum;        printf("%d\n",sum);    }}
0 0
原创粉丝点击