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 |
| 166
|
Codeforces Round 113 (Div. 2) |
FINISHED |
False |
7200 |
443889023 |
March 23, 2012, 3:30 p.m. |
Problems
The warehouse in your shop has n shoe pairs. Each pair is characterized by two integers: its price c i and its size s i . We know that on this very day all numbers s i are different, that is, there is no more than one pair of each size. The shop has m customers who came at the same time. The customer number i has d i money and the size of his feet equals l i . The customer number i can buy the pair number j , if c j ≤ d i , and also if l i = s j or l i = s j - 1 ; that is, it is necessary that he has enough money to pay for the shoes. It is also necessary that the size of his feet equals to or is less by 1 than the size of the shoes he chooses. Your task is to sell some customers pairs of shoes (a pair per person) so as to maximize the sum of the sold pairs c j that is, the profit. It is guaranteed that each customer buys no more than one pair and each pair will be bought by no more than one customer. The first input line contains the only integer n ( 1 ≤ n ≤ 10 5 ) — the number of shoe pairs in the warehouse. Then n lines contain the descriptions of pairs of shoes as two integers c i and s i ( 1 ≤ c i , s i ≤ 10 9 ), the numbers are separated by a space. It is guaranteed that all numbers s i are different. The next line contains an integer m ( 1 ≤ m ≤ 10 5 ) — the number of customers in the shop. Next m lines contain the customers' descriptions as two integers d i and l i ( 1 ≤ d i , l i ≤ 10 9 ), the numbers are separated by a space. In the first line print the only integer — the maximum profit you can get from selling shoes. In the second line print an integer k — the number of shoe pairs you will sell. In the following k lines print the descriptions of the sold pairs — two space-separated integers where the first number is the customer's number and the second number is the number of the shoes the customer will buy. You can print pairs of numbers "the customer's number and the shoes' number" in any order, the customers and the pairs of shoes are numbere |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
3540138 |
Choojae |
D |
April 15, 2013, 9:34 a.m. |
OK |
GNU C++ |
TESTS |
64 |
265 |
10854400 |
|
2400 |
|
4216147 |
Mex-Mans |
D |
Aug. 2, 2013, 7:44 a.m. |
OK |
GNU C++ |
TESTS |
64 |
280 |
12185600 |
|
2400 |
|
12562105 |
HanHansoul |
D |
Aug. 16, 2015, 2:20 p.m. |
OK |
GNU C++ |
TESTS |
64 |
280 |
12390400 |
|
2400 |
|
40991646 |
ReaLNero1 |
D |
July 31, 2018, 12:46 a.m. |
OK |
GNU C++ |
TESTS |
64 |
310 |
7680000 |
|
2400 |
|
22195273 |
XuYipei |
D |
Nov. 13, 2016, 3:14 p.m. |
OK |
GNU C++ |
TESTS |
64 |
310 |
11776000 |
|
2400 |
|
17189698 |
DukeOfYork |
D |
April 6, 2016, 2:08 p.m. |
OK |
GNU C++ |
TESTS |
64 |
310 |
14028800 |
|
2400 |
|
14311969 |
VastoLorde95 |
D |
Nov. 17, 2015, 11:57 a.m. |
OK |
GNU C++ |
TESTS |
64 |
312 |
7168000 |
|
2400 |
|
5620712 |
PSDEV |
D |
Jan. 5, 2014, 8:42 a.m. |
OK |
GNU C++ |
TESTS |
64 |
312 |
7475200 |
|
2400 |
|
5435095 |
masaoh |
D |
Dec. 13, 2013, 9:41 p.m. |
OK |
GNU C++ |
TESTS |
64 |
312 |
7475200 |
|
2400 |
|
5435110 |
masaoh |
D |
Dec. 13, 2013, 9:45 p.m. |
OK |
GNU C++ |
TESTS |
64 |
312 |
7577600 |
|
2400 |
|
9068029 |
Alister |
D |
Dec. 10, 2014, 3:43 a.m. |
OK |
GNU C++0x |
TESTS |
64 |
780 |
11366400 |
|
2400 |
|
29141100 |
GreyMaster |
D |
Aug. 2, 2017, 11:01 p.m. |
OK |
GNU C++11 |
TESTS |
64 |
280 |
16076800 |
|
2400 |
|
19904712 |
xianl |
D |
Aug. 16, 2016, 10:10 a.m. |
OK |
GNU C++11 |
TESTS |
64 |
372 |
25395200 |
|
2400 |
|
10784367 |
delta_4d |
D |
April 19, 2015, 5:13 p.m. |
OK |
GNU C++11 |
TESTS |
64 |
374 |
15974400 |
|
2400 |
|
17075415 |
freebsdx |
D |
March 31, 2016, 2 p.m. |
OK |
GNU C++11 |
TESTS |
64 |
404 |
9728000 |
|
2400 |
|
42723337 |
ivanilos |
D |
Sept. 10, 2018, 4:48 a.m. |
OK |
GNU C++11 |
TESTS |
64 |
404 |
26419200 |
|
2400 |
|
10732296 |
Maestr0 |
D |
April 15, 2015, 2:15 p.m. |
OK |
GNU C++11 |
TESTS |
64 |
434 |
15872000 |
|
2400 |
|
51398077 |
xielinhan |
D |
March 17, 2019, 5:45 a.m. |
OK |
GNU C++11 |
TESTS |
64 |
434 |
20480000 |
|
2400 |
|
54498355 |
WOSHIGEPACHONG2 |
D |
May 22, 2019, 7 p.m. |
OK |
GNU C++11 |
TESTS |
64 |
436 |
20480000 |
|
2400 |
|
60765973 |
ysy20021208 |
D |
Sept. 18, 2019, 10:58 a.m. |
OK |
GNU C++11 |
TESTS |
64 |
498 |
15257600 |
|
2400 |
|
28134021 |
free4all |
D |
June 29, 2017, 7:35 a.m. |
OK |
GNU C++11 |
TESTS |
64 |
498 |
22528000 |
|
2400 |
|
26047177 |
RNS_JKS |
D |
April 1, 2017, 8:30 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
342 |
12390400 |
|
2400 |
|
26047341 |
RNS_JKS |
D |
April 1, 2017, 8:39 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
372 |
12390400 |
|
2400 |
|
47256979 |
lukomskiy |
D |
Dec. 19, 2018, 10:50 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
372 |
16998400 |
|
2400 |
|
43646856 |
terminator |
D |
Oct. 1, 2018, 2:06 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
374 |
10444800 |
|
2400 |
|
49827241 |
ZNI |
D |
Feb. 12, 2019, 12:16 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
434 |
29081600 |
|
2400 |
|
57201448 |
vjudge1 |
D |
July 17, 2019, 1:53 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
436 |
18227200 |
|
2400 |
|
38333599 |
DeshiBasara |
D |
May 16, 2018, 9:43 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
436 |
18227200 |
|
2400 |
|
44371017 |
Corvus |
D |
Oct. 15, 2018, 6:59 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
436 |
24985600 |
|
2400 |
|
49389785 |
yuming |
D |
Feb. 3, 2019, 9:10 a.m. |
OK |
GNU C++14 |
TESTS |
64 |
468 |
16076800 |
|
2400 |
|
57195990 |
Lucky_Glass |
D |
July 17, 2019, 12:13 p.m. |
OK |
GNU C++14 |
TESTS |
64 |
468 |
18227200 |
|
2400 |
|
53968283 |
vjudge1 |
D |
May 10, 2019, 6:54 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
342 |
35328000 |
|
2400 |
|
53968183 |
Piurko |
D |
May 10, 2019, 6:49 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
342 |
35328000 |
|
2400 |
|
49505130 |
vjudge3 |
D |
Feb. 5, 2019, 5:09 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
374 |
14950400 |
|
2400 |
|
61115055 |
MinecraftFuns |
D |
Sept. 23, 2019, 12:35 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
404 |
7475200 |
|
2400 |
|
49504089 |
BinaryBoy |
D |
Feb. 5, 2019, 4:40 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
404 |
14950400 |
|
2400 |
|
63428202 |
ftiasch |
D |
Oct. 26, 2019, 8:26 a.m. |
OK |
GNU C++17 |
TESTS |
64 |
466 |
13516800 |
|
2400 |
|
57465263 |
UnstoppableChillMachine |
D |
July 21, 2019, 3:19 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
466 |
19148800 |
|
2400 |
|
54536046 |
ggawryal |
D |
May 23, 2019, 8:14 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
466 |
20684800 |
|
2400 |
|
54536070 |
vjudge1 |
D |
May 23, 2019, 8:15 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
466 |
20787200 |
|
2400 |
|
54247023 |
vjudge3 |
D |
May 16, 2019, 3:20 p.m. |
OK |
GNU C++17 |
TESTS |
64 |
468 |
12288000 |
|
2400 |
|
9000639 |
deadhunter07 |
D |
Dec. 6, 2014, 1:56 p.m. |
OK |
Java 6 |
TESTS |
64 |
778 |
26112000 |
|
2400 |
|
9062423 |
deadhunter07 |
D |
Dec. 9, 2014, 6:43 p.m. |
OK |
Java 6 |
TESTS |
64 |
1964 |
27033600 |
|
2400 |
|
17197980 |
DukeOfYork |
D |
April 7, 2016, 1:55 a.m. |
OK |
Java 7 |
TESTS |
64 |
748 |
72089600 |
|
2400 |
|
17197971 |
DukeOfYork |
D |
April 7, 2016, 1:53 a.m. |
OK |
Java 7 |
TESTS |
64 |
810 |
71987200 |
|
2400 |
|
17197915 |
DukeOfYork |
D |
April 7, 2016, 1:45 a.m. |
OK |
Java 7 |
TESTS |
64 |
842 |
76800000 |
|
2400 |
|
17553314 |
mikcorer |
D |
April 28, 2016, 1:43 p.m. |
OK |
Java 8 |
TESTS |
64 |
1246 |
50176000 |
|
2400 |
|
11053515 |
A.Elahi |
D |
May 9, 2015, 9:50 a.m. |
OK |
Java 8 |
TESTS |
64 |
1464 |
145203200 |
|
2400 |
|
4849785 |
antofik |
D |
Oct. 23, 2013, 9:14 a.m. |
OK |
MS C# |
TESTS |
64 |
1746 |
58163200 |
|
2400 |
|
7939424 |
JaoChenJzhong |
D |
Sept. 24, 2014, 5:49 p.m. |
OK |
MS C++ |
TESTS |
64 |
340 |
27648000 |
|
2400 |
|
9002094 |
deadhunter07 |
D |
Dec. 6, 2014, 3:10 p.m. |
OK |
MS C++ |
TESTS |
64 |
342 |
13516800 |
|
2400 |
|
9063806 |
Dotokoto |
D |
Dec. 9, 2014, 10:07 p.m. |
OK |
MS C++ |
TESTS |
64 |
436 |
23859200 |
|
2400 |
|
8870146 |
West_coastPWNZ |
D |
Nov. 27, 2014, 1:44 p.m. |
OK |
MS C++ |
TESTS |
64 |
498 |
12083200 |
|
2400 |
|
8864317 |
Wanderer18 |
D |
Nov. 26, 2014, 8:55 p.m. |
OK |
MS C++ |
TESTS |
64 |
686 |
11264000 |
|
2400 |
|
9068717 |
kVAS |
D |
Dec. 10, 2014, 6:13 a.m. |
OK |
MS C++ |
TESTS |
64 |
966 |
37068800 |
|
2400 |
|
9068687 |
kVAS |
D |
Dec. 10, 2014, 6:06 a.m. |
OK |
MS C++ |
TESTS |
64 |
966 |
40345600 |
|
2400 |
|
8870113 |
West_coastPWNZ |
D |
Nov. 27, 2014, 1:41 p.m. |
OK |
MS C++ |
TESTS |
64 |
1028 |
12083200 |
|
2400 |
|
9062820 |
odolokhova |
D |
Dec. 9, 2014, 7:37 p.m. |
OK |
MS C++ |
TESTS |
64 |
1028 |
17203200 |
|
2400 |
|
9061779 |
odolokhova |
D |
Dec. 9, 2014, 5:27 p.m. |
OK |
MS C++ |
TESTS |
64 |
1028 |
17612800 |
|
2400 |
remove filters
Back to search problems