Kotlin Heroes: Episode 3

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1297 Kotlin Heroes: Episode 3 FINISHED False 9000 154542311 Feb. 27, 2020, 1:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 31 ) I Falling Blocks PROGRAMMING *special data structures

B"Recently, Polycarp has invented a new mobile game with falling blocks. In the game, n blocks are falling down, one at a time, towards a flat surface with length d units. Each block can be represented as a rectangle with coordinates from l_i to r_i and unit height, dropped downwards from very high up. A block falls until it comes in contact with the flat surface or any other block. Let's define that block a covers block b if l_a <= l_b <= r_b <= r_a . Consider what happens when a new block i falls. If the new (upper) block i comes in contact with any block j such that block i does not cover block j , block i will stick to block j , and no blocks will disappear. Otherwise, all blocks that block i covers and is in contact with will be vaporized, and block i will continue falling with the ability to vaporize lower blocks. For example, consider what happens when three blocks (1,2) , (2,3) and (1,3) fall, in that order. The first block will stick to the flat surface. Then, the second block will stick to the first block. Finally, the third block will vaporize the second block, keep falling, vaporize the first block, and stick to the flat surface. After each block falls, help Polycarp determine how many blocks will remain! The first line contains two integers n and d ( 1 <= n, d <= 10^5 ) -- the number of falling blocks and the length of the flat surface. The i -th of the following n lines contains integers l_i and r_i ( 1 <= l_i <= r_i <= d ) -- the coordinates of the i -th block. Output n integers. The i -th integer should be the number of blocks that will be left after the i -th block falls. The first example is explained above. In the second example, this is what happens after each block falls: "...

Tutorials

Kotlin Heroes: Episode 3 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
72039390 armoking I Feb. 28, 2020, 1:41 p.m. OK Kotlin TESTS 66 342 19148800
72083658 Spheniscine I Feb. 29, 2020, 8:11 a.m. OK Kotlin TESTS 66 358 17100800
72039319 armoking I Feb. 28, 2020, 1:40 p.m. OK Kotlin TESTS 66 373 19148800
72083903 Spheniscine I Feb. 29, 2020, 8:16 a.m. OK Kotlin TESTS 66 389 18227200
72039097 armoking I Feb. 28, 2020, 1:36 p.m. OK Kotlin TESTS 66 529 19251200
72025347 Ebrahim_Emon I Feb. 28, 2020, 9:13 a.m. OK Kotlin TESTS 66 764 54579200
71987336 Egor I Feb. 27, 2020, 3:51 p.m. OK Kotlin TESTS 66 826 54681600
72039007 armoking I Feb. 28, 2020, 1:35 p.m. OK Kotlin TESTS 66 951 19251200
71993007 Benq I Feb. 27, 2020, 5:16 p.m. OK Kotlin TESTS 66 1325 66560000
72119757 cjtoribio I Feb. 29, 2020, 7:56 p.m. OK Kotlin TESTS 66 1886 53043200

remove filters

Back to search problems