Codeforces Round #467 (Div. 2) A. Olympiad[输入一组数,求该数列合法的子集个数]
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 && 非空子集 && 选定某个数且其他数<=该数
[分析]:先想要用标记数组,后来发现直接用set对非零数去重求set的size就可以了
[代码]:
#include<bits/stdc++.h>
#define MOD 1000000007
const int maxn = ;
using namespace std;
typedef long long ll; int main()
{
set<int> s;
int n,a[maxn];
cin>>n;
for(int i=;i<n;i++){
cin>>a[i];
if(a[i]!=){
s.insert(a[i]);
}
}
cout<<s.size()<<endl;
}
模拟/stl
Codeforces Round #467 (Div. 2) A. Olympiad[输入一组数,求该数列合法的子集个数]的更多相关文章
- Codeforces Round #467 (div.2)
Codeforces Round #467 (div.2) 我才不会打这种比赛呢 (其实本来打算打的) 谁叫它推迟到了\(00:05\) 我爱睡觉 题解 A. Olympiad 翻译 给你若干人的成绩 ...
- Codeforces Round #467 (Div. 2) B. Vile Grasshoppers
2018-03-03 http://codeforces.com/problemset/problem/937/B B. Vile Grasshoppers time limit per test 1 ...
- Codeforces Round #467 Div.2题解
A. Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Codeforces Round #467 (Div. 1) B. Sleepy Game
我一开始把题目看错了 我以为是博弈.. 这题就是一个简单的判环+dfs(不简单,挺烦的一题) #include <algorithm> #include <cstdio> #i ...
- Codeforces Round #467 (Div. 1). C - Lock Puzzle
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> ...
- Codeforces Round #467 Div. 1
B:显然即相当于能否找一条有长度为奇数的路径使得终点出度为0.如果没有环直接dp即可.有环的话可以考虑死了的spfa,由于每个点我们至多只需要让其入队两次,复杂度变成了优秀的O(kE).事实上就是拆点 ...
- Codeforces Round #467 (Div. 2) E -Lock Puzzle
Lock Puzzle 题目大意:给你两个字符串一个s,一个t,长度<=2000,要求你进行小于等于6100次的shift操作,将s变成t, shift(x)表示将字符串的最后x个字符翻转后放到 ...
- Codeforces Round #467 (Div. 2) B. Vile Grasshoppers[求去掉2-y中所有2-p的数的倍数后剩下的最大值]
B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #346 (Div. 2) E - New Reform 无相图求环
题目链接: 题目 E. New Reform time limit per test 1 second memory limit per test 256 megabytes inputstandar ...
随机推荐
- java十分钟速懂知识点——引用
一.由健忘症引起的问题 今天闲来没事在日志中瞟见了个OutOfMemoryError错误,不由得想到前一段时间看到一篇面经里问到Java中是否有内存泄露,这个很久以前是留意过的,大体记得内存溢出和内存 ...
- android shape.xml 文件使用
设置背景色可以通过在res/drawable里定义一个xml,如下: <?xml version="1.0" encoding="utf-8"?> ...
- Git之2分钟教程
Git之2分钟入门 普通人:“借我1000块钱”.程序猿:“借你1024吧,凑个整”. 今天是1024,是我们程序员的节日,在此,首先祝各位程序猿以及程序媛们节日快乐~然后送出一份节日礼物,没错,就是 ...
- linux实用命令-待补充
- du 查看目录大小 - du -h 带有单位显示目录信息 - df 查看磁盘大小 - df -h 带有单位显示磁盘信息 - netstat 显示网络状态信息 - 清除僵尸进程 ps -eal | ...
- ZigBee学习三 UART通信
ZigBee学习三 UART通信 在使用串口时,只需掌握ZigBee协议栈提供的串口操作相关的三个函数即可. uint8 HalUARTOpen(uint8 port,halUARTCfg_t *co ...
- SPOJ 422 Transposing is Even More Fun ——Burnside引理
这题目就比较有趣了. 大概题目中介绍了一下计算机的储存方法,给一个$2^a*2^b$的矩阵. 求转置.但是只能交换两个数,求所需要的步数. 首先可以把变化前后的位置写出来,构成了许多的循环.左转将狼踩 ...
- 挖煤(coal)
挖煤(coal) solution 我好弱,啥也想不到. 想了很久dp,这有后效性啊. 结果倒着做就可以了,因为后面的不会影响前面的. 考虑前面的影响后面:挖煤相当于让后面所有a[I]*(1+k%) ...
- system权限无法访问外挂SD卡
总结Android应用system权限无法访问SD卡问题 包括android1.6 解决方案http://hi.baidu.com/yunlongchn/item/7d6636d8547317ffca ...
- 使用iview如何使左上的添加按钮和右上的搜索框和边框对齐
使用iview如何使左上的添加按钮和右上的搜索框和边框对齐呢? 效果如下: 使用iview自带的Grid 栅格进行布局,但是由于按钮和搜索框的大小不正好是一个栅格的宽度,所以不是很好跳转,且栅格也不支 ...
- Do not use built-in or reserved HTML elements as component id: header
刚刚在搭建项目时发现控制台报错 查找发现是因为组件名称所致,也就是当我们起名一个header.vue的组件时,我们安装的vue插件会自动把name设置为default 这就造成了错误 把header修 ...