Friday, May 7, 2021

codeforces 158A Solution Next Round (codeforces 158A) (rank 800*)

158A. Next Round

Problem Link: https://codeforces.com/problemset/problem/158/A

Solution 1:
import java.util.*;

public class A158 {

    public static Scanner scn = new Scanner(System.in);

    public static int passedStudent(int[] arrint valueint k) {
        int counter = 0;

        for (int i = 0i < arr.lengthi++) {
            if (value <= arr[i] && arr[i] > 0)
                counter++;
            else
                return counter;
        }
        return counter;
    }

    public static void input(int[] arr) {
        for (int i = 0i < arr.lengthi++)
            arr[i] = scn.nextInt();
    }

    public static void main(String[] argv) {
        int n = scn.nextInt();
        int k = scn.nextInt();
        int[] arr = new int[n];
        input(arr);
        if (arr[0] == 0)
            System.out.println(0);
        else
            System.out.println(passedStudent(arrarr[k - 1], k));
    }
}

No comments:

Post a Comment

Thanks

Climate Crisis and Innovation: Navigating Earth's Future

Climate Change: Recent Events and Technological Solutions 1. The Escalating Climate Crisis The climate crisis has intensified in recent year...