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
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; }
相关文章推荐
- unity3d创建材质时,无法添加材质贴图的解决方法
- 判断一个字符是否是中文
- Quartz学习一
- iOS - UITextFieldKeyBoardPan为时间选择器
- 使用AJAX异步提交表单的几种方式
- mybatis整合spring、springmvc时业务层无法进行事务回滚问题解决
- SecureCRT突然假死的问题(Ctrl+S)
- LintCode_166_链表倒数第n个节点
- Rman 备份参数 及 oracle 进程理论
- 五大常用算法:分治、动态规划、贪心、回溯、分支限界算法
- Fbric、Ansible、Docker、Chaos Monkey:DevOps工具的年中回顾
- dt dl列表布局
- hdoj 5256 序列变换 【LIS 变形】
- android_design support library-Snackbar
- 深入剖析CSS变形transform(3d)
- (6)
- hdoj 5253 连接的管道 【MST】
- win7 下oracle卸载
- struts.xml不在默认位置,导致出现HTTP Status 404 - There is no Action mapped for namespace [/] and action name [
- Codeforces 588E Duff in the Army 【树链剖分维护区间前k小】