hdu 5210 Delete

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

 1 #include<algorithm>

 2 #include<iostream>

 3 #include<cstdlib>

 4 #include<cstdio>

 5 using std::sort;

 6 const int Max_N = 1010;

 7 int arr[Max_N];

 8 int main() {

 9 #ifdef LOCAL

10     freopen("in.txt", "r", stdin);

11     freopen("out.txt", "w+", stdout);

12 #endif

13     int n, k, tot, ret, cnt;

14     while (~scanf("%d", &n)) {

15         tot = 0;

16         for (int i = 0; i < n; i++) scanf("%d", &arr[i]);

17         scanf("%d", &k);

18         sort(arr, arr + n);

19         for (int i = 0; i < n;) {

20             ret = arr[i], cnt = 0;

21             for (; ret == arr[i]; i++) cnt++;

22             tot++;

23         }

24         if (n - tot <= k) printf("%d\n", n - k);

25         else printf("%d\n", tot);

26     }

27     return 0;

28 }
View Code

 

你可能感兴趣的:(delete)