ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1263. Elections

Find Mistake ( If You Can !!! :D )
Posted by Thunderbolt 17 Mar 2015 01:53
int main()
{
    int n , m;
    cin >> n >> m;

    int *counter = new int [n];

    for ( int i = 0 ; i < m ; i++ )
    {
        int temp;
        cin >> temp;
        counter[temp-1]++;
    }

    for ( int i = 0 ; i < n ; i++ )
    {
        float result = (float)counter[i] * (float)100 / (float)m;
        printf ("%.2f%%\n" , result);
    }

    delete[] counter;

    return 0;
}

(WA On Test 1)
Re: Find Mistake ( If You Can !!! :D )
Posted by Zahar-160019 19 Dec 2016 19:48
Where is "cout"?
Re: Find Mistake ( If You Can !!! :D )
Posted by Evans_DoN 3 Nov 2019 16:21
printf() also does the same work as cout<<
Re: Find Mistake ( If You Can !!! :D )
Posted by Evans_DoN 3 Nov 2019 16:47
I think the problem is from using int*counter.. Try using vector<int>counter(n); instead..
It worked fine when i tested it with the rest of your code