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
Once, four Roman merchants met in a Roman mansion to discuss their trading plans. They faced the following problem: they traded the same type of goods, and if they traded in the same city, they would inevitably incur losses. They decided to divide up the cities between them where they would trade. The map of Rome can be represented in this problem as a plane with certain points marked — the cities of the Roman Empire. The merchants decided to choose a certain dividing point ((x_0, y_0)). Then, in a city with coordinates ((x_i, y_i)), the first merchant sells goods if (x_0 \le x_i) and (y_0 \le y_i); the second merchant sells goods if (x_0 > x_i) and (y_0 \le y_i); the third merchant sells goods if (x_0 \le x_i) and (y_0 > y_i); the fourth merchant sells goods if (x_0 > x_i) and (y_0 > y_i). The merchants want to choose ((x_0, y_0)) in such a way as to maximize the smallest number of cities that any of them gets (i. e., as fair as possible). Please find such a point for them. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((4 \le n \le 10^5)) — the number of cities on the map. Each of the next (n) lines contains two integers (x_i, y_i) ((-10^9 \le x_i, y_i \le 10^9)) — the coordinates of the cities. Note that some points may coincide. This is because some cities may be so close that they cannot be distinguished on the map at the given scale. It is guaranteed that the sum of (n) over all test cases does not exceed (10^5). For each test case, in the first line, print a single integer (k) ((0 \le k \le \frac{n}{4})) — the maximum possible number of cities that each merchant can get at a minimum. In the second line, print two integers (x_0) and (y_0) ((|x_0|, |y_0| \le 10^9)) — the coordinate |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
294582435 |
mban259 |
C |
Dec. 3, 2024, 8:16 a.m. |
OK |
C# 10 |
TESTS |
17 |
905 |
38502400 |
|
|
|
294552119 |
joelgun14 |
C |
Dec. 3, 2024, 7 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
155 |
0 |
|
|
|
294692348 |
Kuaikule |
C |
Dec. 3, 2024, 9:39 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
22 |
156 |
4096000 |
|
|
|
294606347 |
triccsr |
C |
Dec. 3, 2024, 11:39 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
171 |
5632000 |
|
|
|
294579134 |
Darko1 |
C |
Dec. 3, 2024, 8:06 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
171 |
5632000 |
|
|
|
294672034 |
TravellingSalesman |
C |
Dec. 3, 2024, 6:10 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
21 |
187 |
2560000 |
|
|
|
294556416 |
Amoo_Safar |
C |
Dec. 3, 2024, 7:08 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
187 |
5632000 |
|
|
|
294572763 |
fishy15 |
C |
Dec. 3, 2024, 7:47 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
202 |
0 |
|
|
|
294575330 |
Watersphere |
C |
Dec. 3, 2024, 7:54 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
202 |
7270400 |
|
|
|
294568540 |
little_vegetable |
C |
Dec. 3, 2024, 7:36 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
17 |
202 |
7270400 |
|
|
|
294623927 |
PEIMUDA |
C |
Dec. 3, 2024, 1:16 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
18 |
202 |
8908800 |
|
|
|
294558733 |
fishcathu |
C |
Dec. 3, 2024, 7:13 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
17 |
140 |
102400 |
|
|
|
294551477 |
Sana |
C |
Dec. 3, 2024, 6:58 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
17 |
155 |
102400 |
|
|
|
294620903 |
JoanhLan |
C |
Dec. 3, 2024, 1 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
18 |
155 |
10649600 |
|
|
|
294562200 |
yishangtanhuan |
C |
Dec. 3, 2024, 7:21 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
17 |
155 |
20889600 |
|
|
|
294576462 |
_WD_ |
C |
Dec. 3, 2024, 7:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
17 |
155 |
24064000 |
|
|
|
294670568 |
MisterReaper |
C |
Dec. 3, 2024, 6 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
21 |
156 |
0 |
|
|
|
294639119 |
Ichinoseyang |
C |
Dec. 3, 2024, 2:39 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
21 |
156 |
0 |
|
|
|
294659512 |
NotFound |
C |
Dec. 3, 2024, 4:46 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
21 |
171 |
0 |
|
|
|
294584484 |
2018haha |
C |
Dec. 3, 2024, 8:22 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
17 |
171 |
102400 |
|
|
|
294564220 |
superguymj |
C |
Dec. 3, 2024, 7:25 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
17 |
171 |
102400 |
|
|
|
294719679 |
Benq |
C |
Dec. 4, 2024, 5:47 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
22 |
108 |
102400 |
|
|
|
294657121 |
lotusblume |
C |
Dec. 3, 2024, 4:30 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
21 |
124 |
0 |
|
|
|
294709780 |
Empty_Dust |
C |
Dec. 4, 2024, 3:24 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
22 |
124 |
102400 |
|
|
|
294627777 |
the_Despair_ |
C |
Dec. 3, 2024, 1:37 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
18 |
124 |
20070400 |
|
|
|
294628693 |
the_Despair_ |
C |
Dec. 3, 2024, 1:41 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
18 |
125 |
20070400 |
|
|
|
294664583 |
MeteorYe |
C |
Dec. 3, 2024, 5:20 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
21 |
140 |
102400 |
|
|
|
294564298 |
IceKnight1093 |
C |
Dec. 3, 2024, 7:25 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
17 |
140 |
102400 |
|
|
|
294540710 |
jiangly |
C |
Dec. 3, 2024, 6:40 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
17 |
140 |
102400 |
|
|
|
294568343 |
dolbaeb |
C |
Dec. 3, 2024, 7:35 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
17 |
140 |
4096000 |
|
|
|
294576995 |
minstdfx |
C |
Dec. 3, 2024, 7:58 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
17 |
140 |
4915200 |
|
|
|
294632282 |
nguyenquocthao00 |
C |
Dec. 3, 2024, 2:01 p.m. |
OK |
Go |
TESTS |
18 |
437 |
111820800 |
|
|
|
294711474 |
0x3F |
C |
Dec. 4, 2024, 3:51 a.m. |
OK |
Go |
TESTS |
22 |
1233 |
21196800 |
|
|
|
294712194 |
0x3F |
C |
Dec. 4, 2024, 4:01 a.m. |
OK |
Go |
TESTS |
22 |
1233 |
22528000 |
|
|
|
294565913 |
Quasicoherent |
C |
Dec. 3, 2024, 7:29 a.m. |
OK |
Java 21 |
TESTS |
17 |
1374 |
18432000 |
|
|
|
294639202 |
profchi |
C |
Dec. 3, 2024, 2:40 p.m. |
OK |
Java 8 |
TESTS |
21 |
1952 |
5324800 |
|
|
|
294575204 |
hxu10 |
C |
Dec. 3, 2024, 7:53 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
780 |
47820800 |
|
|
|
294572151 |
PNJ0714 |
C |
Dec. 3, 2024, 7:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
1359 |
16486400 |
|
|
|
294670035 |
Haksell |
C |
Dec. 3, 2024, 5:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
1624 |
37990400 |
|
|
|
294617975 |
LMeyling |
C |
Dec. 3, 2024, 12:44 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
1655 |
46592000 |
|
|
|
294618067 |
nguyenquocthao00 |
C |
Dec. 3, 2024, 12:44 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
1687 |
34201600 |
|
|
|
294572011 |
LMeyling |
C |
Dec. 3, 2024, 7:45 a.m. |
OK |
PyPy 3-64 |
TESTS |
17 |
1718 |
46592000 |
|
|
|
294654180 |
golomb |
C |
Dec. 3, 2024, 4:12 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
2639 |
47308800 |
|
|
|
294662093 |
Haksell |
C |
Dec. 3, 2024, 5:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
2936 |
60006400 |
|
|
|
294665222 |
Haksell |
C |
Dec. 3, 2024, 5:24 p.m. |
OK |
PyPy 3-64 |
TESTS |
21 |
2967 |
70451200 |
|
|
remove filters
Back to search problems