hdu 5210 Delete

来源:互联网 发布:上海至寻网络怎么样 编辑:程序博客网 时间:2024/06/06 02:39

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5210
简单题如下:

#include<algorithm>#include<iostream>#include<cstdlib>#include<cstdio>using std::sort;const int Max_N = 1010;int arr[Max_N];int main() {#ifdef LOCAL    freopen("in.txt", "r", stdin);    freopen("out.txt", "w+", stdout);#endif    int n, k, tot, ret, cnt;    while (~scanf("%d", &n)) {        tot = 0;        for (int i = 0; i < n; i++) scanf("%d", &arr[i]);        scanf("%d", &k);        sort(arr, arr + n);        for (int i = 0; i < n;) {            ret = arr[i], cnt = 0;            for (; ret == arr[i]; i++) cnt++;            tot++;        }        if (n - tot <= k) printf("%d\n", n - k);        else printf("%d\n", tot);    }    return 0;}
0 0
原创粉丝点击