problem "Next Round" VK 2012

Revision en1, by SayaPintar, 2021-05-28 15:46:51

my code written with c# give wrong output, im fail in testcase 7

Testcase: 5 5 3 2 1 0 0 this my code:

static void Main(string[] args) { string input = Console.ReadLine(); string[] proses = input.Split(' ');

//inputan setiap array.
        string Inputn = Console.ReadLine();
        string[] array = Inputn.Split(' ');
        int[] array1 = new int[int.Parse(proses[0])];
        //
        //base case
        for(int x =0; x < array.Length; x++)
        {
            array1[x] = int.Parse(array[x]);
        }
       int pos = int.Parse(proses[1]);
       int basis = int.Parse(array[pos-1]);
        //
        int count = 0;
       if (basis == 0 && array1.Sum() == 0)
        {
            Console.WriteLine(0);
        }
        else
        {
           for(int c =0; c < array1.Length; c++)
            {
                if(array1[c] >= array1[basis - 1] && array1[c] > 0)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
        Console.ReadLine();

    }

i think my code was give correct result(i think 5) but expected 3...

anyone help me.. i wonder how why my code doesnt work?

another note: i rebuild my code and im not use Linq (Where) and work perfectly if i do that with manually.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English SayaPintar 2021-05-28 15:46:51 1544 Initial revision (published)