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

WA task1263
Posted by AlexStrong 9 Jul 2020 23:16
I don’t understand what is the mistake here. Help pls
              string[] val = Console.ReadLine().Split(' ');

               double[] k = new double[10000];

              for(int i = 0; i < Convert.ToInt32(val[1]); i++)
               {
                   string s = Console.ReadLine();
                   k[Convert.ToInt32(s) - 1]++;
               }
               double swap = 0;
               for(int i = 0; i < k.Length-1; i++)
               {
                   for(int j = i + 1; j < k.Length - i - 1; j++)
                   {
                       if (k[j+1] > k[j])
                       {
                           swap = k[j+1];
                           k[j+1] = k[j];
                           k[j] = swap;
                       }
                   }
               }
               for (int i = 0; i < Convert.ToInt32(val[0]); i++)
               {

                   Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:N2}", (100 * k[i]) / Convert.ToDouble(val[1]))+"%");
               }