HDU 5210 DELETE
来源:互联网 发布:linux tcp ip 转发 编辑:程序博客网 时间:2024/06/02 05:31
题目链接:delete
题面:
Delete
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 636 Accepted Submission(s): 326
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 integerN(0<N≤100) .
The second line containsN integers a1,a2,...,aN(1≤ai≤N) , denoting the integers WLD plays with.
The third line contains one integerK(0≤K<N) .
For each case:
The first line contains one integer
The second line contains
The third line contains one integer
Output
For each case:
Print one integer. It denotes the maximum of different numbers remain after the deletion.
Print one integer. It denotes the maximum of different numbers remain after the deletion.
Sample Input
41 3 1 2 1
Sample Output
3Hintif WLD deletes a 3, the numbers remain is [1,1,2],he'll get 2 different numbers.if WLD deletes a 2, the numbers remain is [1,1,3],he'll get 2 different numbers.if WLD deletes a 1, the numbers remain is [1,2,3],he'll get 3 different numbers.
Source
BestCoder Round #39 ($)
解题:
利用set计数即可。
代码:
#include <iostream>#include <cmath> #include <set>using namespace std;int main(){int n,k,tmp,ans;while(scanf("%d",&n)!=EOF){set <int> store;for(int i=1;i<=n;i++){scanf("%d",&tmp);store.insert(tmp);}scanf("%d",&k);if(n==store.size()){ans=n-k;//刚好,就直接减 }else{tmp=n-store.size();//可以不减少的前提下,提供的最大数量 if(tmp>=k)//够减,,数量不变 ans=store.size();else //不够减,减去多余的后,再减种类数 ans=store.size()-(k-tmp);}printf("%d\n",ans);}return 0;}
0 0
- hdu 5210 Delete
- HDU-5210-Delete(Oier)
- HDU 5210 Delete
- hdu 5210 Delete
- HDU 5210 DELETE
- HDU 5210 Delete
- HDU 5210 Delete
- hdu 5210 Delete
- hdu 5210 Delete(set)
- HDU ACM 5210 Delete 水题
- Hdoj 5210 Delete 【水】
- hdoj 5210 Delete 【水题】
- DELETE
- delete
- delete
- DELETE
- delete
- delete
- 有关new出一个指针,将该指针指向另一个指针,释放不掉的问题
- 模电实验答案(带题目)
- OJ系统(ACM/NOI)基本输入输出教程
- 在 Windows 8 上安装 vSphere Client 5.0 时失败,并显示错误:此产品只能安装在 Windows XP SP2 及更高版本上 (2102145)
- 每日一题D
- HDU 5210 DELETE
- 图的创建,深搜,广搜(基于临接表实现)
- 黑马程序员----Date Calendar使用细节
- 比特币是什么?深入浅出滴分析
- 图像超分辨技术(Image Super Resolution)
- POJ 3904(容斥原理)
- 黑马程序员-File类文件操作,知识梳理与简单应用
- 第三章第46题
- 黑马程序员-OC学习笔记-点方法、成员变量作用域以及set方法和get方法@property的综合题