Codeforces Round #467 (Div. 2) A. Olympiad

Source: Internet
Author: User
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 is to determine the set of participants to is awarded with diplomas with RE SPECT 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 was awarded, all participants with score not less than he score should also be awarded.

Determine the number of ways to choose a subset of participants that would receive the diplomas. Input

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 in least one participant has Non-zero score. Output

Print a single integer-the desired number of ways. Examples input Copy

4
1 3) 3 2
Output
3
Input Copy
3
1 1 1
Output
1
Input Copy
4
42 0) 0 42
Output
1

Test instructions: There are n individuals, you can set the bar, so that all people not less than this score award, 0 points can not win the prize, ask you how many ways to divide.

Idea: It is obvious that there are several different numbers, that is, a few fraction division method, note 0 Except, you can use the set container to weight, directly output set the number of elements is the answer.

#include <bits/stdc++.h>
#define LL Long long
using namespace std;
set<ll>st;
ll N,x,ans;
int main ()
{
    while (~scanf ("%lld", &n))
    {
        st.clear ();
        for (ll i=1;i<=n;i++)
        {
            scanf ("%lld", &x);
            if (x==0) continue;
            St.insert (x);
        }
        Ans=st.size ();
        printf ("%lld\n", ans);
    }
    return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.