Tetris cattle off network

Links: https://www.nowcoder.com/questionTerminal/9407e24a70b04fedba4ab3bd3ae29704?source=relative
Source: Cattle-off network

Xiao Yi There is an old game consoles, has a top classic game Tetris. Because it is relatively old, so the general rules of Tetris and different.
A total of n columns on the screen, every time there is a 1 x 1 block of randomly dropped, in the same column, the box will fall stacked over the previous block, when a whole block row are occupied, this line will be eliminated, and get 1 point.
One day, Xiao Yi has opened a game, when the first m squares to play down he felt too bored turned off, Xiao Yi hope you get him to tell him the score of this game round.

 

Enter a description:
The first line of the two numbers n, m 
the number of the second line m, c

1

, c

2

, ... , c

m

 , c

i

It denotes the i th block of falling columns 
where 1 <= n, m <= 1000, 1 <= c

i

 <= n


Output Description:
Xiao Yi inning game scores obtained
Example 1

Entry

3 9
1 1 2 2 2 3 1 2 3

Export

2


import java.util.*;
public class Main {
    public static void main(String[] args) {
        System.out.println(grade());


    }
    public static int grade(){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] array = new int[n];
        for(int i = 0;i < m;i++){
            array[scanner.nextInt()-1]++;
        }
        Arrays.sort(array);
        return array[0];

    }

}

 

Guess you like

Origin www.cnblogs.com/hetaoyuan/p/11335102.html