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
B"The chef has cooked n dishes yet again: the i -th dish consists of a_i grams of fish and b_i grams of meat. Banquet organizers consider two dishes i and j equal if a_i=a_j and b_i=b_j at the same time. The banquet organizers estimate the variety of n dishes as follows. The variety of a set of dishes is equal to the number of different dishes in it. The less variety is, the better. In order to reduce the variety, a taster was invited. He will eat exactly m_i grams of food from each dish. For each dish, the taster determines separately how much fish and how much meat he will eat. The only condition is that he will eat exactly m_i grams of the i -th dish in total. Determine how much of what type of food the taster should eat from each dish so that the value of variety is the minimum possible. If there are several correct answers, you may output any of them. The first line of input data contains an integer t ( 1 <= q t <= q 10^4 ) -- the number of test cases. Each test case's description is preceded by a blank line. Next comes a line that contains an integer n ( 1 <= q n <= q 2 cdot 10^5 ) -- the number of dishes. Then follows n lines, i -th of which contains three integers a_i , b_i and m_i ( 0 <= q a_i, b_i <= 10^6 ; 0 <= m_i <= a_i+b_i ) -- the mass of fish in i -th dish, the mass of meat in i -th dish and how many grams in total the taster should eat in i -th dish. The sum of all n values for all input data sets in the test does not exceed 2 cdot 10^5 . For each test case, print on the first line the minimum value of variety that can be achieved by eating exactly m_i grams of food (for all i from 1 to n ) from a dish i . Then print n lines that describe a way to do this: the i -th line should contain two integers x_i and y_i ( 0 <= q x_i <= q"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
134148138 |
Gassa |
H |
Nov. 2, 2021, 7:21 p.m. |
OK |
D |
TESTS |
25 |
327 |
27545600 |
|
|
134127039 |
LZHMmiao |
H |
Nov. 2, 2021, 4:27 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
187 |
8294400 |
|
|
134125653 |
Parios |
H |
Nov. 2, 2021, 4:24 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
233 |
34304000 |
|
|
134138003 |
Gorgo |
H |
Nov. 2, 2021, 5:21 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
234 |
7372800 |
|
|
134177161 |
stoorz |
H |
Nov. 3, 2021, 5:36 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
234 |
57139200 |
|
|
134168128 |
Rainer1116 |
H |
Nov. 3, 2021, 3:51 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
265 |
8294400 |
|
|
134155148 |
Baraa_Armoush |
H |
Nov. 2, 2021, 9:24 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
265 |
13824000 |
|
|
134169079 |
ZhuaBa |
H |
Nov. 3, 2021, 4:12 a.m. |
OK |
GNU C++14 |
TESTS |
25 |
295 |
38912000 |
|
|
134129047 |
Denisov |
H |
Nov. 2, 2021, 4:31 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
311 |
14745600 |
|
|
134138182 |
MohammadAghil |
H |
Nov. 2, 2021, 5:22 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
342 |
19251200 |
|
|
134155736 |
Bedo_Sayed |
H |
Nov. 2, 2021, 9:38 p.m. |
OK |
GNU C++14 |
TESTS |
25 |
358 |
21299200 |
|
|
134135810 |
m7m3d_anwar |
H |
Nov. 2, 2021, 5:01 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
187 |
8294400 |
|
|
134133296 |
igba |
H |
Nov. 2, 2021, 4:45 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
202 |
5836800 |
|
|
134162073 |
_Ruri_ |
H |
Nov. 3, 2021, 1:14 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
202 |
8294400 |
|
|
134135609 |
0x24 |
H |
Nov. 2, 2021, 5 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
218 |
9625600 |
|
|
134134113 |
luanfreitas5 |
H |
Nov. 2, 2021, 4:49 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
248 |
12288000 |
|
|
134151022 |
tbzard |
H |
Nov. 2, 2021, 8:07 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
249 |
35942400 |
|
|
134149738 |
Ruki |
H |
Nov. 2, 2021, 7:45 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
280 |
13004800 |
|
|
134127982 |
farmerboy |
H |
Nov. 2, 2021, 4:29 p.m. |
OK |
GNU C++17 |
TESTS |
25 |
280 |
65740800 |
|
|
134161237 |
CSQ31 |
H |
Nov. 3, 2021, 12:48 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
295 |
12185600 |
|
|
134160984 |
NegaTeeF |
H |
Nov. 3, 2021, 12:39 a.m. |
OK |
GNU C++17 |
TESTS |
25 |
296 |
19763200 |
|
|
134167973 |
I_francis |
H |
Nov. 3, 2021, 3:47 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
156 |
9216000 |
|
|
134129398 |
xyf007 |
H |
Nov. 2, 2021, 4:32 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
171 |
7680000 |
|
|
134160340 |
froggyzhang |
H |
Nov. 3, 2021, 12:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
171 |
18329600 |
|
|
134124913 |
maxlevel_spyofgame |
H |
Nov. 2, 2021, 4:23 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
202 |
56524800 |
|
|
134158566 |
Bungmint |
H |
Nov. 2, 2021, 11:09 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
233 |
64307200 |
|
|
134125326 |
igorfardoc |
H |
Nov. 2, 2021, 4:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
234 |
27648000 |
|
|
134145686 |
java. |
H |
Nov. 2, 2021, 6:47 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
264 |
86937600 |
|
|
134136653 |
SevenDawns |
H |
Nov. 2, 2021, 5:08 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
265 |
18841600 |
|
|
134156636 |
_DaNeK_ |
H |
Nov. 2, 2021, 10:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
280 |
19353600 |
|
|
134126951 |
brunomont |
H |
Nov. 2, 2021, 4:27 p.m. |
OK |
GNU C++17 (64) |
TESTS |
25 |
280 |
20582400 |
|
|
134178536 |
mars4 |
H |
Nov. 3, 2021, 5:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
139 |
20480000 |
|
|
134143990 |
sserdoubleh |
H |
Nov. 2, 2021, 6:25 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
140 |
11571200 |
|
|
134164008 |
ZENGJIE |
H |
Nov. 3, 2021, 2:12 a.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
156 |
11264000 |
|
|
134135028 |
Ahmadsm2005 |
H |
Nov. 2, 2021, 4:55 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
156 |
24473600 |
|
|
134152441 |
Mcqueen_tote_italia |
H |
Nov. 2, 2021, 8:31 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
264 |
155648000 |
|
|
134134890 |
generic_placeholder_name |
H |
Nov. 2, 2021, 4:54 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
265 |
64614400 |
|
|
134144392 |
piyush_pransukhka |
H |
Nov. 2, 2021, 6:30 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
280 |
20172800 |
|
|
134143635 |
machine_solution |
H |
Nov. 2, 2021, 6:20 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
280 |
23756800 |
|
|
134145857 |
hackerbhaiya |
H |
Nov. 2, 2021, 6:50 p.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
280 |
31641600 |
|
|
134161456 |
yiq |
H |
Nov. 3, 2021, 12:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
25 |
280 |
205926400 |
|
|
134130546 |
Dukkha |
H |
Nov. 2, 2021, 4:34 p.m. |
OK |
Java 11 |
TESTS |
25 |
1013 |
32256000 |
|
|
134134345 |
knightL |
H |
Nov. 2, 2021, 4:51 p.m. |
OK |
Java 11 |
TESTS |
25 |
1060 |
64512000 |
|
|
134145701 |
dino_merlin |
H |
Nov. 2, 2021, 6:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
25 |
1356 |
13312000 |
|
|
134158177 |
hxu10 |
H |
Nov. 2, 2021, 10:54 p.m. |
OK |
PyPy 3 |
TESTS |
25 |
1200 |
89702400 |
|
|
134173597 |
mkawa2 |
H |
Nov. 3, 2021, 4:43 a.m. |
OK |
PyPy 3 |
TESTS |
25 |
1231 |
76595200 |
|
|
134128234 |
huikang |
H |
Nov. 2, 2021, 4:30 p.m. |
OK |
PyPy 3-64 |
TESTS |
25 |
1778 |
143462400 |
|
|
remove filters
Back to search problems