Codeforces 937A - Olympiad
A. Olympiad
题目链接:http://codeforces.com/problemset/problem/937/A
1 second
256 megabytes
standard input
standard output
The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points.
As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the following criteria:
- At least one participant should get a diploma.
- None of those with score equal to zero should get awarded.
- When someone is awarded, all participants with score not less than his score should also be awarded.
Determine the number of ways to choose a subset of participants that will receive the diplomas.
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of participants.
The next line contains a sequence of n integers a1, a2, ..., an (0 ≤ ai ≤ 600) — participants' scores.
It's guaranteed that at least one participant has non-zero score.
Print a single integer — the desired number of ways.
- 4
1 3 3 2
- 3
- 3
1 1 1
- 1
- 4
42 0 0 42
- 1
There are three ways to choose a subset in sample case one.
- Only participants with 3 points will get diplomas.
- Participants with 2 or 3 points will get diplomas.
- Everyone will get a diploma!
The only option in sample case two is to award everyone.
Note that in sample case three participants with zero scores cannot get anything.
题解:取重 排除 0
- #include <iostream>
- #include <algorithm>
- #include <set>
- using namespace std;
- int a[];
- int main()
- {
- int n;
- set<int> s;
- while(cin>>n){
- s.clear();
- int x;
- for(int i=;i<n;i++){
- cin>>a[i];
- s.insert(a[i]);
- }
- int sum=s.size();
- sort(a,a+n);
- if(a[]==) sum--;
- cout<<sum<<endl;
- }
- return ;
- }
Codeforces 937A - Olympiad的更多相关文章
- CodeForces 222D - Olympiad
第一行给出两个个数字k和n,第二三行分别有k个数字,求将第二.三行之间的数字相互组合,求最多有多少个组合的和不小于n 纯粹暴力 #include <iostream> #include & ...
- Codeforces 最大流 费用流
这套题目做完后,一定要反复的看! 代码经常出现的几个问题: 本机测试超时: 1.init函数忘记写. 2.addedge函数写成add函数. 3.边连错了. 代码TLE: 1.前向星边数组开小. 2. ...
- Codeforces Round #306 (Div. 2) B. Preparing Olympiad dfs
B. Preparing Olympiad Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550 ...
- DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad
题目传送门 /* DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : */ #include <cstdio> #include <iostream&g ...
- Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics)
A. Even Subset Sum Problem 题意 给出一串数,找到其中的一些数使得他们的和为偶数 题解 水题,找到一个偶数或者两个奇数就好了 代码 #include<iostream& ...
- codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)
B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as inte ...
- Codeforces Round #347 (Div. 2) C. International Olympiad 找规律
题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins
http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的&qu ...
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) C. Classroom Watch
http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: ...
随机推荐
- 如何将wordpress所有文章批量改为已发布状态
用wordpress建站的一个好处就是bd站长工具平台上有数据结构插件,可以认为bd默认支持wp发展,另外一种建站程序是discuz.我们在用wordpress发布文章时,特别是那种多用户投稿的文章一 ...
- 帝国cms如何调用指定id的文章到首页?
小美女用帝国cms建了一个站,现在首页调出指定id为12的文章作为推荐,附带文章摘要,她想用代码的形式直接掉用,以后方便修改.那么,帝国cms如何调用指定id的文章呢?指定信息id,不是调用指定栏目i ...
- wxPython:消息对话框MessageDialog
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "M ...
- pattern.define注意事项
1.PAT:最好不要所有的关键字后面都用|,导致整条pattern变成无限统配.
- 使用awk处理文本
http://blog.wuxu92.com/using-awk/ 在Liux下我们经常需要对一些文本文档做一些处理,尤其像从日志里提取一些数据,这是我们一般会用awk工具和sed工具去实现需求,这里 ...
- (转)fabric 一个链码如何调用另一个链码
使用开发模式测试 可以使用~/hyfa/fabric-samples/chaincode-docker-devmode/启动fabric,具体过程略 用同一个链码注册2个服务 root@2ee7b51 ...
- 2018-2019-1 20189221 《Linux内核原理与分析》第七周作业
2018-2019-1 20189221 <Linux内核原理与分析>第七周作业 实验六 分析Linux内核创建一个新进程的过程 代码分析 task_struct: struct task ...
- 2018-2019-1 20189221《Linux内核原理与分析》第五周作业
2018-2019-1 20189221<Linux内核原理与分析>第五周作业 实验四 实验过程 当用户态进程调用一个系统调用时,cpu切换到内核态并开始执行一个内核函数. 在Linux中 ...
- 数据分析与挖掘 - R语言:贝叶斯分类算法(案例一)
一个简单的例子!环境:CentOS6.5Hadoop集群.Hive.R.RHive,具体安装及调试方法见博客内文档. 名词解释: 先验概率:由以往的数据分析得到的概率, 叫做先验概率. 后验概率:而在 ...
- keras 分类回归 损失函数与评价指标
1.目标函数 (1)mean_squared_error / mse 均方误差,常用的目标函数,公式为((y_pred-y_true)**2).mean()(2)mean_absolute_error ...