Codeforces Round 982 (Div. 2)

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
2027 Codeforces Round 982 (Div. 2) FINISHED False 7200 46452323 Oct. 26, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 22010 ) A Rectangle Arrangement PROGRAMMING geometry implementation math

You are coloring an infinite square grid, in which all cells are initially white. To do this, you are given (n) stamps. Each stamp is a rectangle of width (w_i) and height (h_i). You will use each stamp exactly once to color a rectangle of the same size as the stamp on the grid in black. You cannot rotate the stamp, and for each cell, the stamp must either cover it fully or not cover it at all. You can use the stamp at any position on the grid, even if some or all of the cells covered by the stamping area are already black. What is the minimum sum of the perimeters of the connected regions of black squares you can obtain after all the stamps have been used? Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \le n \le 100)). The (i)-th of the next (n) lines contains two integers (w_i) and (h_i) ((1 \le w_i, h_i \le 100)). For each test case, output a single integer — the minimum sum of the perimeters of the connected regions of black squares you can obtain after all the stamps have been used. In the first test case, the stamps can be used as shown on the left. Each stamp is highlighted in its own color for clarity. After all these stamps are used, there is one black region (as shown on the right), and its perimeter is (20). It can be shown that there is no way of using the stamps that yields a lower total perimeter. In the second test case, the second and third stamps can be used entirely inside the first one, so the minimum perimeter is equal to (8).

Tutorials

Codeforces Round #982 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
288198404 sohrab A Oct. 26, 2024, 8:07 p.m. OK C# 10 TESTS 3 92 2662400

remove filters

Back to search problems