Codeforces #467 (Div. 2) A. Olympiad

此文章介绍了一个关于Berland Olympiad的信息学竞赛评分策略问题。作为编程委员会的负责人,你需要确定获得证书的参赛者名单,确保至少有一名得分非零的参赛者获奖,并且所有得分不低于某位获奖者的选手都应当获奖。文章提供了问题描述、输入输出示例及一个使用C++编写的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Olympiad

题目描述

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.

样例

inputCopy
4
1 3 3 2
output
3
inputCopy
3
1 1 1
output
1
inputCopy
4
42 0 0 42
output
1

题意

就是求不重复的数字除了0有几个
set搞一下

AC代码

#include <bits/stdc++.h>
using namespace std;

#define CLR(a,b) memset(a,(b),sizeof(a))
#define LL long long

const int MAXN = 1e3+10;
const double eps = 1e-15;

int main()
{
    int n, x;
    cin >> n ;
    set<int> s;
    for(int i = 0; i < n; i++)
        cin >> x, s.insert(x);
    int k = s.size();
//    set<int>::iterator it;
//    for(it = s.begin(); it != s.end(); it++) {
//        if(*it)
//            k++;
//    }
    if(*s.begin()==0) k -= 1;
    cout << k << endl;
return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值