codeforces——961A Tetris
本文是博主原创文章,未经允许不得转载。
我在csdn上也同步发布了此文,链接 https://blog.csdn.net/umbrellalalalala/article/details/79891552
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.
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.
Print one integer — the amount of points you will receive.
3 9 1 1 2 2 2 3 1 2 3
2
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].
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相关推荐
- Codeforces 题目合集+分类+代码 【Updating...】【361 in total】
961A - Tetris 模拟 ...
- CodeForces 375D Tree and Queries
传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...
- 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)
题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...
- 【codeforces 812C】Sagheer and Nubian Market
[题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...
- CodeForces 获得数据
针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...
- codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...
题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...
- CodeForces 595A
题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...
- codeforces A. Jeff and Digits 解题报告
题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这 ...
- Codeforces Round #506 (Div. 3)
Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...
- Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)
Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...
最新文章
- SQLite 删除表
- 简陋的会计凭证金额输入控件
- LaTeX 使用 bib 管理参考文献时,引用网络资源 URL 导致排版难看的问题
- C/C++语言函数学习(2)qsort
- 使用MAT工具分析内存溢出
- iphonex价格_正二品:帮你解读IphoneX回收价,为何二手市场iphoneX依旧吃香
- WEB前端开发职业学习路线初级完整版
- Spring包的依赖关系以及提供下载
- ubuntu 用户管理 adduser vs useradd
- Java大厂面试100题,你面试时总会用到的!
- Delphi – TCanvas.CopyRect方法中参数CopyMode的意义
- 2021-10-1825. K 个一组翻转链表
- c10k java_c10k问题及其解决方案
- python金融分析小知识(7)——股票收盘价曲线可视化
- 解决树莓派播放音频时耳机插线了但没有声音
- figma制作点击下拉菜单
- 04Java异常-3. 异常处理方式之try..catch
- CSS3新特性详细介绍
- 日志php-error错误日志查看
- PHP人才招聘网站源码