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. 思路: ...
随机推荐
- gh-ost:不一样的在线表结构变更
简介: 2016年8月份,shlomi-noach在GitHub Engineering发文宣布gh-ost开源.gh-ost是什么?一个不依赖触发器实现的在线表结构变更工具. 对于数据库运维人员来说 ...
- Linux软件包的安装(rpm+yum)
概述: 1.rpm软件包管理命令软件包的获取a.光盘镜像中有很多软件包可以使用:先挂载光盘,再查看软件包b.从软件的官网获取 .rpm 安装rpm包 ipm -ivh 软件包名称删除rpm包 ipm ...
- [django]前后端分离之JWT用户认证
在前后端分离开发时为什么需要用户认证呢?原因是由于HTTP协定是不储存状态的(stateless),这意味着当我们透过帐号密码验证一个使用者时,当下一个request请求时它就把刚刚的资料忘了.于是我 ...
- springboot测试
一.单元测试 在开发阶段的时候最重要的是单元测试了,springboot对单元测试的支持已经很完善了. 1.在pom包中添加spring-boot-starter-test包引用 <depend ...
- (转)Ctrl+H 浪潮Raid配置文档
说明 本手册适用于LSI芯片Raid卡 包括但不限于Inspur 2008/2108 Raid卡.LSI 9240/9260/9261/9271 等Raid卡. 不同型号的Raid卡在某些功能上的支持 ...
- Python Singleton模式
注意:在重写__new__方法时,object.__new__(cls)不能传参数 #!/usr/bin/env python # -*- coding: utf-8 -*- class Single ...
- DLNg[结构化ML项目]第二周迁移学习+多任务学习
1.迁移学习 比如要训练一个放射科图片识别系统,但是图片非常少,那么可以先在有大量其他图片的训练集上进行训练,比如猫狗植物等的图片,这样训练好模型之后就可以转移到放射科图片上,模型已经从其他图片中学习 ...
- jenkins 常用插件和配置项介绍和使用
jenkins 上搜索不到的插件可以在如下地址下载: http://updates.jenkins-ci.org/download/plugins/ 1.Notification Plugin 介绍: ...
- node代码打包为 exe文件---端口进程关闭demo
最近用到 java,用tomcat起的服务,经常服务关了,对应的进程还在跑,导致再次启动服务失败,需要手动关闭进程. 使用 dos命令虽然只有两行,总是输,也很烦. netstat -ano | fi ...
- HttpContext.Current.Items的用途
HTTP是一个无状态的协议.每次的请求都是独立的,它的执行情况和结果与前面的请求和之后的请求是无直接关系的,它不会受前面的请求应答情况直接影响,也不会直接影响后面的请求应答情况.而实际上,我们的系统往 ...