CF961A.Tetris

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a following process.

There is a platform with nn columns. 1×11 \times 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.

When all of the nn columns have at least one square in them, the bottom row is being removed. You will receive 11 point for this, and all the squares left will fall down one row.

You task is to calculate the amount of points you will receive.

你将面对如下过程:

有一个包含 nn 列的平台。大小为 1×11 \times 1 的方块会依次出现在该平台的某些列中。若某列中尚无任何方块,则新方块将占据该列最底部的一行;否则,新方块将出现在该列中最高方块的正上方。

当所有 nn 列中均至少存在一个方块时,最底行将被移除。此时你将获得 11 分,且所有剩余方块均向下掉落一行。

你的任务是计算你总共能获得多少分。

输入格式

The first line of input contain 2 integer numbers nn and mm (1≤n,m≤10001 \le n, m \le 1000) — the length of the platform and the number of the squares.

The next line contain mm integer numbers c1,c2,…,cmc_1, c_2, \dots, c_m (1≤ci≤n1 \le c_i \le n) — column in which ii-th square will appear.

输入的第一行包含两个整数 nn 和 mm(1≤n,m≤10001 \le n, m \le 1000)—— 分别表示平台的长度和方块的数量。

第二行包含 mm 个整数 c1,c2,…,cmc_1, c_2, \dots, c_m(1≤ci≤n1 \le c_i \le n)—— 表示第 ii 个方块将出现的列号。

输出格式

Print one integer — the amount of points you will receive.

输出一个整数——你将获得的分数。

输入输出样例

  • 输入#1

    3 9
    1 1 2 2 2 3 1 2 3

    输出#1

    2

说明/提示

In the sample case the answer will be equal to 22 because after the appearing of 66-th square will be removed one row (counts of the squares on the platform will look like [2 3 1][2~ 3~ 1], and after removing one row will be [1 2 0][1~ 2~ 0]).

After the appearing of 99-th square counts will be [2 3 1][2~ 3~ 1], and after removing one row it will look like [1 2 0][1~ 2~ 0].

So the answer will be equal to 22.

在样例中,答案等于 22,因为第 66 个方块出现后将被移除一行(此时平台上方块数量变为 [2 3 1][2~ 3~ 1],移除一行后变为 [1 2 0][1~ 2~ 0])。

第 99 个方块出现后,方块数量为 [2 3 1][2~ 3~ 1],移除一行后变为 [1 2 0][1~ 2~ 0]。

因此答案为 22。

输入解题思路,AI测评打分。不知道怎么写?

首页