您的位置:首页 > 其它

hdoj 5210 Delete 【水题】

2016-04-07 17:22 676 查看
题目链接:hdoj 5210 Delete

Delete

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 1049 Accepted Submission(s): 509

Problem Description

WLD likes playing with numbers. One day he is playing with N integers. He wants to delete K 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 100)

For each case:

The first line contains one integer N(0

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define CLR(a, b) memset(a, (b), sizeof(a))
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
bool vis[110];
int main()
{
int n;
while(scanf("%d", &n) != EOF) {
CLR(vis, false); int sum1 = 0, sum2 = 0;
for(int i = 0; i < n; i++) {
int v; scanf("%d", &v);
if(!vis[v]) {
sum1++;
vis[v] = true;
}
else {
sum2++;
}
}
int k; scanf("%d", &k);
int ans;
if(k <= sum2) {
ans = sum1;
}
else {
k -= sum2;
ans = sum1 - k;
}
printf("%d\n", ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: