本文是博主原创文章,未经允许不得转载。

我在csdn上也同步发布了此文,链接 https://blog.csdn.net/umbrellalalalala/article/details/79891552

题目链接 http://codeforces.com/problemset/problem/961/A
【题目】
You are given a following process.

There is a platform with n columns. 1×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 n columns have at least one square in them, the bottom row is being removed. You will receive 1 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.

Input

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

The next line contain mm integer numbers c1,c2,…,cm (1≤ci≤n) — column in which i-th square will appear.

Output

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

Example
Input
3 9
1 1 2 2 2 3 1 2 3

Output
2

Note

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

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

So the answer will be equal to 2.

【大意及分析】
有点像俄罗斯方块,大意就是在n列的区域中,随机在给定的若干列依次出现m个小方块,每个小方块都会占据本列空闲位置的最下方,当每一列的最后一行都有小方块时,这一行就会被删掉,分数加一,然后上面的方块下落一行。
我们只需要利用数组表示每一列的方块个数即可(注意不要用二维数组表示每一列的方块的情况,我们并不需要知晓方块的具体位置,那样算法复杂度会变大)。
【示例代码】
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #define MAX_N 1005
 4 int a[MAX_N];
 5
 6 int main() {
 7     int score = 0;
 8     int n, m, temp, bottom_score = 0;
 9     bool judge;
10     scanf("%d %d", &n, &m);
11     for (int i = 0; i < n; i++)
12         a[i] = 0;
13     for (int i = 0; i < m; i++) {
14         scanf("%d", &temp);
15         a[temp - 1]++;
16         judge = true;
17         for (int k = 0; k < n; k++) {
18             if (a[k] == bottom_score) {
19                 judge = false;
20                 break;
21             }
22         }
23         if (judge) {
24             score++;
25             bottom_score++;
26         }
27     }
28     printf("%d\n", score);
29     return 0;
30 }  

转载于:https://www.cnblogs.com/umbrellalalalala/p/8824188.html

codeforces——961A Tetris相关推荐

  1. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

  2. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  3. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  4. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  5. CodeForces 获得数据

    针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...

  6. codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...

    题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...

  7. CodeForces 595A

    题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...

  8. codeforces A. Jeff and Digits 解题报告

    题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这 ...

  9. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  10. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

最新文章

  1. SQLite 删除表
  2. 简陋的会计凭证金额输入控件
  3. LaTeX 使用 bib 管理参考文献时,引用网络资源 URL 导致排版难看的问题
  4. C/C++语言函数学习(2)qsort
  5. 使用MAT工具分析内存溢出
  6. iphonex价格_正二品:帮你解读IphoneX回收价,为何二手市场iphoneX依旧吃香
  7. WEB前端开发职业学习路线初级完整版
  8. Spring包的依赖关系以及提供下载
  9. ubuntu 用户管理 adduser vs useradd
  10. Java大厂面试100题,你面试时总会用到的!
  11. Delphi – TCanvas.CopyRect方法中参数CopyMode的意义
  12. 2021-10-1825. K 个一组翻转链表
  13. c10k java_c10k问题及其解决方案
  14. python金融分析小知识(7)——股票收盘价曲线可视化
  15. 解决树莓派播放音频时耳机插线了但没有声音
  16. figma制作点击下拉菜单
  17. 04Java异常-3. 异常处理方式之try..catch
  18. CSS3新特性详细介绍
  19. 日志php-error错误日志查看
  20. PHP人才招聘网站源码

热门文章

  1. 决策树(一)--ID3
  2. 嵌入式系统——软件测试工程
  3. “21天好习惯”第一期-11
  4. 堆的应用之优先级队列
  5. Hbase ConnectionFactory
  6. c/c++_消除非标准警告
  7. 数据推动变革 PMC创新存储方案应对挑战
  8. INIT: vesion 2.88 booting
  9. jQuery 源码系列(二)init 介绍
  10. 关于 gzip, deflate, zlib, LZ77