题号:NC226681
时间限制:C/C++/Rust/Pascal 5秒,其他语言10秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Dr. Orooji’s children have played Tetris but are not willing to help Dr. O with a related problem.
Dr. O’s children don’t realize that Dr. O is lucky to have access to 100+ great problem solvers and
great programmers today!
Dr. O knows the length of the base for a 2D box and wants to figure out the needed height for the
box. Dr. O will drop some 2D blocks (rectangles) on the base. A block will go down until it lands
on the base or is stopped by an already-dropped block (i.e., it lands on that block). After all the
blocks have been dropped, we can determine the needed height for the box – the tallest column is
the needed height (please see pictures on the next page corresponding to Sample Input/Output).
输入描述:
The first input line contains two integers:b(1 ≤b≤ 100), indicating the length of the base andr
(1 ≤r≤50), indicating the number of blocks (rectangular pieces) to be dropped. Each of the next
rinput lines contains three integers: a block’shorizontal lengthh(1 ≤h≤100), the block’svertical
lengthv(1 ≤v≤100), andc(c≥1), the leftmost column the block is dropped into. Assume that
thehandcvalues will be such that the block will not go beyond the box base, i.e., (c+h–1)≤b.
输出描述:
Print the needed height for the box (the tallest column is the height).
示例1
输入
复制
10 4
2 3 1
4 2 2
1 7 6
1 3 4