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. 思路: ...
随机推荐
- ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes怎么处理
今天ytkah进行了应急数据库恢复,用Navicat for Mysql导入sql文件出现ERROR 1153 (08S01): Got a packet bigger than 'max_allow ...
- AutoML初创公司探智立方:模型的物竞天择与适者生存
从回归分析的出现到深度学习的蓬勃发展,这条算法的进化路线与其说是「机器替代人」,不如说是「机器帮助人类完毕我们不擅长的事」. 这份「不擅长」列表里有「不擅长从大量数据中寻找规律」.「不擅长同一时候完毕 ...
- Python日期与字符串互转
import datetime #str -> date detester = '2017-01-01' date = datetime.datetime.strptime(detester,' ...
- JVM内存管理(转)
转载出处:http://blog.csdn.net/wind5shy/article/details/8349559 模型 JVM运行时数据区域 JVM执行Java程序的过程中,会使用到各种数据区域, ...
- JavaScript 全栈工程师培训教程 - 阮一峰
http://www.ruanyifeng.com/blog/2016/11/javascript.html https://github.com/ruanyf/jstraining 我现在的技术方向 ...
- MyBatis——模糊查询
在mybatis中可以使用三种模糊查询的方式: <!-- 模糊查询 --> <select id="selectListByTitle" parameterTyp ...
- Jmeter测试报告
服务器: 2个CPU,每个CPU 1个核,4G内存 20G硬盘 客户端(Jmeter):2个CPU,每个2个核,4+8内存 500G硬盘 ---------------------------- ...
- SQL中查询前几条或者中间某几行数据limit
SELECT * FROM table LIMIT [offset,] rows | rows OFFSET offset 使用查询语句的时候,要返回前几条或者中间某几行数据,用Llimit 可 ...
- CentOS里alias命令
alias命令 功能描述:我们在进行系统的管理工作一定会有一些我们经常固定使用,但又很长的命令.那我们可以给这些这一长串的命令起一个别名.之后还需要这一长串命令时就可以直接以别名来替代了.系统中已经有 ...
- huawei
线程堆栈(Thread Stack)和托管堆(Managed Heap) 每个正在运行的程序都对应着一个进程 (process),在一个进程内部,可以有一个或多个线程(thread),每个线程都拥有一 ...