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.
Problems
The game field is a matrix of size (10^9 \times 10^9), with a cell at the intersection of the (a)-th row and the (b)-th column denoted as ((a, b)). There are (n) monsters on the game field, with the (i)-th monster located in the cell ((x_i, y_i)), while the other cells are empty. No more than one monster can occupy a single cell. You can move one monster to any cell on the field that is not occupied by another monster at most once . After that, you must select one rectangle on the field; all monsters within the selected rectangle will be destroyed. You must pay (1) coin for each cell in the selected rectangle. Your task is to find the minimum number of coins required to destroy all the monsters. The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains a single integer (n) ((1 \le n \le 2 \cdot 10^5)) — the number of monsters on the field. The following (n) lines contain two integers (x_i) and (y_i) ((1 \le x_i, y_i \le 10^9)) — the coordinates of the cell with the (i)-th monster. All pairs ((x_i, y_i)) are distinct. It is guaranteed that the sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer — the minimum cost to destroy all (n) monsters. Below are examples of optimal moves, with the cells of the rectangle to be selected highlighted in green. |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
321720025 |
Survivor45 |
D |
May 28, 2025, 3:31 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
124 |
0 |
|
|
|
321718939 |
ayushkumar_31 |
D |
May 28, 2025, 3:13 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
124 |
102400 |
|
|
|
321712476 |
Ignacio36 |
D |
May 28, 2025, 1:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
124 |
102400 |
|
|
|
321670170 |
Yolandina |
D |
May 27, 2025, 3:24 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
124 |
102400 |
|
|
|
321720116 |
yuyangyyy |
D |
May 28, 2025, 3:32 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
124 |
4812800 |
|
|
|
321715388 |
mzibrahmi |
D |
May 28, 2025, 2:13 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
125 |
102400 |
|
|
|
321622807 |
Ten_words |
D |
May 27, 2025, 9:51 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
125 |
102400 |
|
|
|
321716543 |
buyuv |
D |
May 28, 2025, 2:34 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
125 |
1638400 |
|
|
|
321714357 |
accuber |
D |
May 28, 2025, 1:53 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
125 |
88268800 |
|
|
|
321586468 |
Codingsfan |
D |
May 27, 2025, 5:05 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
14 |
125 |
160358400 |
|
|
|
321717930 |
FARHADUL_ISLAM |
D |
May 28, 2025, 2:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
108 |
102400 |
|
|
|
321650125 |
PrahaladVk |
D |
May 27, 2025, 1:01 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
0 |
|
|
|
321736434 |
Faysal_Chowdhury |
D |
May 28, 2025, 5:51 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
0 |
|
|
|
321695750 |
b.piash |
D |
May 27, 2025, 7:03 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
0 |
|
|
|
321670444 |
MuBai_Shiro |
D |
May 27, 2025, 3:26 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
0 |
|
|
|
321628478 |
Super_Dinosaur |
D |
May 27, 2025, 10:31 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
0 |
|
|
|
321633613 |
JSTCoder |
D |
May 27, 2025, 11:11 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
102400 |
|
|
|
321645979 |
YUYIZHI |
D |
May 27, 2025, 12:34 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
102400 |
|
|
|
321636620 |
RGB_ICPC8 |
D |
May 27, 2025, 11:32 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
102400 |
|
|
|
321632846 |
Ichinoseyang |
D |
May 27, 2025, 11:05 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
14 |
109 |
102400 |
|
|
|
321724741 |
_infinite_ |
D |
May 28, 2025, 4:41 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
108 |
0 |
|
|
|
321649373 |
Daniil_Tolstyh |
D |
May 27, 2025, 12:56 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
108 |
0 |
|
|
|
321592349 |
wzl19371 |
D |
May 27, 2025, 5:58 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
108 |
102400 |
|
|
|
321653896 |
Shreyxyz__112005 |
D |
May 27, 2025, 1:26 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
108 |
2867200 |
|
|
|
321617426 |
ddbjiang |
D |
May 27, 2025, 9:14 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
109 |
0 |
|
|
|
321718381 |
kailtsit |
D |
May 28, 2025, 3:04 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
109 |
0 |
|
|
|
321680215 |
zhangfangming |
D |
May 27, 2025, 4:42 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
109 |
0 |
|
|
|
321621508 |
orzch |
D |
May 27, 2025, 9:42 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
109 |
0 |
|
|
|
321618580 |
ddbjiang |
D |
May 27, 2025, 9:21 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
109 |
0 |
|
|
|
321615988 |
ddbjiang |
D |
May 27, 2025, 9:05 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
14 |
109 |
0 |
|
|
|
321722792 |
bluemegane |
D |
May 28, 2025, 4:14 a.m. |
OK |
C# 8 |
TESTS |
14 |
187 |
6656000 |
|
|
|
321701532 |
alicia33 |
D |
May 27, 2025, 8:16 p.m. |
OK |
GNU C11 |
TESTS |
14 |
140 |
3276800 |
|
|
|
321677075 |
lyongwolf |
D |
May 27, 2025, 4:17 p.m. |
OK |
Java 21 |
TESTS |
14 |
312 |
20070400 |
|
|
|
321683222 |
_TokaiTeio_ |
D |
May 27, 2025, 5:05 p.m. |
OK |
Java 21 |
TESTS |
14 |
374 |
1126400 |
|
|
|
321693845 |
Anush_Revankar |
D |
May 27, 2025, 6:42 p.m. |
OK |
Java 21 |
TESTS |
14 |
374 |
7475200 |
|
|
|
321635918 |
parni6ka0 |
D |
May 27, 2025, 11:28 a.m. |
OK |
Java 21 |
TESTS |
14 |
390 |
819200 |
|
|
|
321691146 |
mzip |
D |
May 27, 2025, 6:14 p.m. |
OK |
Java 21 |
TESTS |
14 |
405 |
1433600 |
|
|
|
321675305 |
dwbh21 |
D |
May 27, 2025, 4:03 p.m. |
OK |
Java 21 |
TESTS |
14 |
406 |
819200 |
|
|
|
321581786 |
singhdevansh024 |
D |
May 27, 2025, 4:16 a.m. |
OK |
Java 21 |
TESTS |
14 |
437 |
5632000 |
|
|
|
321647290 |
Abhishek.B |
D |
May 27, 2025, 12:42 p.m. |
OK |
Java 21 |
TESTS |
14 |
468 |
7884800 |
|
|
|
321671670 |
ChrizzyB47 |
D |
May 27, 2025, 3:35 p.m. |
OK |
Java 21 |
TESTS |
14 |
484 |
8089600 |
|
|
|
321671851 |
ChrizzyB47 |
D |
May 27, 2025, 3:37 p.m. |
OK |
Java 21 |
TESTS |
14 |
531 |
7680000 |
|
|
|
321688830 |
Eslam_Ahmed |
D |
May 27, 2025, 5:53 p.m. |
OK |
Java 8 |
TESTS |
14 |
249 |
16486400 |
|
|
|
321586798 |
kasiru_69 |
D |
May 27, 2025, 5:08 a.m. |
OK |
Java 8 |
TESTS |
14 |
827 |
51712000 |
|
|
|
321621108 |
NischayCodes |
D |
May 27, 2025, 9:39 a.m. |
OK |
Java 8 |
TESTS |
14 |
890 |
8192000 |
|
|
|
321667244 |
Sumitsingh7 |
D |
May 27, 2025, 3:03 p.m. |
OK |
Java 8 |
TESTS |
14 |
968 |
95027200 |
|
|
|
321663104 |
satyams_9001 |
D |
May 27, 2025, 2:32 p.m. |
OK |
Java 8 |
TESTS |
14 |
968 |
95027200 |
|
|
|
321622356 |
not_mohith |
D |
May 27, 2025, 9:48 a.m. |
OK |
Java 8 |
TESTS |
14 |
1124 |
33075200 |
|
|
|
321587545 |
sarthaKKharKa_18 |
D |
May 27, 2025, 5:15 a.m. |
OK |
Java 8 |
TESTS |
14 |
1374 |
44646400 |
|
|
|
321589663 |
Idiotic_fellow327 |
D |
May 27, 2025, 5:33 a.m. |
OK |
Java 8 |
TESTS |
14 |
1671 |
39219200 |
|
|
|
321629455 |
2023csb1115 |
D |
May 27, 2025, 10:39 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
1046 |
11673600 |
|
|
|
321600688 |
Calculuslove |
D |
May 27, 2025, 7:04 a.m. |
OK |
PyPy 3 |
TESTS |
14 |
1249 |
32153600 |
|
|
|
321647106 |
sumitmandaliitr |
D |
May 27, 2025, 12:41 p.m. |
OK |
PyPy 3 |
TESTS |
14 |
1546 |
40345600 |
|
|
|
321723758 |
347586774 |
D |
May 28, 2025, 4:28 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
233 |
24268800 |
|
|
|
321661412 |
cmath11 |
D |
May 27, 2025, 2:20 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
265 |
12902400 |
|
|
|
321688477 |
kidus72 |
D |
May 27, 2025, 5:50 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
280 |
15769600 |
|
|
|
321688446 |
kylianm7 |
D |
May 27, 2025, 5:50 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
280 |
15769600 |
|
|
|
321660260 |
hxrshh |
D |
May 27, 2025, 2:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
296 |
31129600 |
|
|
|
321660184 |
whaeee |
D |
May 27, 2025, 2:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
296 |
31129600 |
|
|
|
321710024 |
monocrap |
D |
May 27, 2025, 11:41 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
312 |
33587200 |
|
|
|
321716644 |
huqingchang |
D |
May 28, 2025, 2:36 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
358 |
41574400 |
|
|
|
321614790 |
Katrina55553 |
D |
May 27, 2025, 8:58 a.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
359 |
12902400 |
|
|
|
321684967 |
Messi_00005 |
D |
May 27, 2025, 5:20 p.m. |
OK |
PyPy 3-64 |
TESTS |
14 |
405 |
47104000 |
|
|
|
321581352 |
infinitely_C |
D |
May 27, 2025, 4:11 a.m. |
OK |
Python 3 |
TESTS |
14 |
452 |
64512000 |
|
|
|
321724525 |
andrewliu10523 |
D |
May 28, 2025, 4:38 a.m. |
OK |
Python 3 |
TESTS |
14 |
452 |
96153600 |
|
|
|
321672030 |
AmanRaj-25 |
D |
May 27, 2025, 3:38 p.m. |
OK |
Python 3 |
TESTS |
14 |
499 |
33587200 |
|
|
|
321723547 |
347586774 |
D |
May 28, 2025, 4:25 a.m. |
OK |
Python 3 |
TESTS |
14 |
687 |
32665600 |
|
|
|
321625841 |
___a_s_1_2___ |
D |
May 27, 2025, 10:12 a.m. |
OK |
Python 3 |
TESTS |
14 |
718 |
35123200 |
|
|
|
321621820 |
superdepressedhunbhai |
D |
May 27, 2025, 9:44 a.m. |
OK |
Python 3 |
TESTS |
14 |
875 |
83558400 |
|
|
|
321647370 |
huangjiajing |
D |
May 27, 2025, 12:43 p.m. |
OK |
Python 3 |
TESTS |
14 |
921 |
31641600 |
|
|
|
321638776 |
ksuganthy |
D |
May 27, 2025, 11:46 a.m. |
OK |
Python 3 |
TESTS |
14 |
983 |
34508800 |
|
|
|
321677395 |
ChatIsThisReal |
D |
May 27, 2025, 4:20 p.m. |
OK |
Python 3 |
TESTS |
14 |
984 |
58777600 |
|
|
|
321635046 |
sh.4teen |
D |
May 27, 2025, 11:21 a.m. |
OK |
Python 3 |
TESTS |
14 |
1156 |
150220800 |
|
|
|
321710767 |
PlaceOrientedProgrammer |
D |
May 28, 2025, 12:08 a.m. |
OK |
Rust 2021 |
TESTS |
14 |
62 |
102400 |
|
|
|
321675351 |
fujishu |
D |
May 27, 2025, 4:04 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
109 |
0 |
|
|
|
321651889 |
Ming_Xu |
D |
May 27, 2025, 1:13 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
124 |
18636800 |
|
|
|
321641804 |
DanielAnker |
D |
May 27, 2025, 12:05 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
140 |
3686400 |
|
|
|
321646084 |
Martician |
D |
May 27, 2025, 12:34 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
156 |
13926400 |
|
|
|
321674313 |
Martician |
D |
May 27, 2025, 3:55 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
218 |
14848000 |
|
|
|
321677369 |
Martician |
D |
May 27, 2025, 4:20 p.m. |
OK |
Rust 2021 |
TESTS |
14 |
265 |
14848000 |
|
|
remove filters
Back to search problems