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].
#include<stdio.h>
#include<stdlib.h>
#define MAX_N 1005
int a[MAX_N]; int main() {
int score = ;
int n, m, temp, bottom_score = ;
bool judge;
scanf("%d %d", &n, &m);
for (int i = ; i < n; i++)
a[i] = ;
for (int i = ; i < m; i++) {
scanf("%d", &temp);
a[temp - ]++;
judge = true;
for (int k = ; k < n; k++) {
if (a[k] == bottom_score) {
judge = false;
break;
}
}
if (judge) {
score++;
bottom_score++;
}
}
printf("%d\n", score);
return ;
}
codeforces——961A Tetris的更多相关文章
- Codeforces Round #627 (Div. 3) A - Yet Another Tetris Problem(逻辑)
题意 : 有n个高度,可以使任一高度加二任意次,问最终n个高度可否相同. 思路: 因为添加的2x1的方块不可旋转,只需考虑所有高度是否为同一奇偶性即可. #include <bits/stdc+ ...
- x01.Tetris: 俄罗斯方块
最强大脑有个小孩玩俄罗斯方块游戏神乎其技,那么,就写一个吧,玩玩而已. 由于逻辑简单,又作了一些简化,所以代码并不多. using System; using System.Collections.G ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- CUDA学习,使用shared memory实现Reverse Array
- ROS(indigo)机器人操作系统学习有趣丰富的Gazebo仿真示例evarobot
一直在寻找一个示例可以将ROS学习中常用的基础内容大部分都包含进去,最好还包括Gazebo仿真, 这样即使没有硬件设备,也可以很好的学习ROS相关内容,但又必须有对应的硬件,便于后续研究. 这里,介绍 ...
- MyBatis - 介绍、简单入门程序
JDBC编程中的问题 1. 将SQL语句硬编码到Java代码,不利于系统维护. 设想如何解决:将SQL单独抽取出来,在配置文件(xml方式.properties文件)进行配置. ...
- SpringMVC注解控制器详解
主要包括四类:@Component.@Repository @Service.@Controller 说明: @Controller 控制层,就是我们的action层 @Service 业务逻辑层,就 ...
- css之盒子模型案例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- H5学习之旅-H5的布局(10)
两种实现方式:div和table div实现布局的方式 代码实例 <!DOCTYPE html> <html lang="en"> <head> ...
- 关于C++程序的编码问题
转自: http://blog.chinaunix.net/uid-26790551-id-3190813.html 我们传统的程序基本都只在Windows或只在Linux下运行,Windows程序使 ...
- linux下数学运算器:expr命令(shell中完成数学运算)
expr用法 expr命令一般用于整数值,但也可用于字符串.一般格式为: expr argument operator argument expr也是一个手工命令行计数器. $expr 10 ...
- 怎样使用projectproperty sheet(.vsprops)来管理工程
怎样使用projectproperty sheet(.vsprops)来管理工程 IDE:VS2005 前言 Project Property Sheet的意思是项目属性表,在大型项目中基本上都会使用 ...
- STL - miltimap(可重映射)
#include <iostream> #include <map> #include <string> using namespace std; //Multim ...