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"In the new messenger for the students of the Master's Assistance Center, Keftemerum, an update is planned, in which developers want to optimize the set of messages shown to the user. There are a total of n messages. Each message is characterized by two integers a_i and b_i . The time spent reading the set of messages with numbers p_1, p_2, ldots, p_k ( 1 <= p_i <= n , all p_i are distinct) is calculated by the formula: Large sum_{i=1}^{k} a_{p_i} + sum_{i=1}^{k - 1} |b_{p_i} - b_{p_{i+1}}| Note that the time to read a set of messages consisting of one message with number p_1 is equal to a_{p_1} . Also, the time to read an empty set of messages is considered to be 0 . The user can determine the time l that he is willing to spend in the messenger. The messenger must inform the user of the maximum possible size of the set of messages, the reading time of which does not exceed l . Note that the maximum size of the set of messages can be equal to 0 . The developers of the popular messenger failed to implement this function, so they asked you to solve this problem. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 5 cdot 10^4 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains two integers n and l ( 1 <= q n <= q 2000 , 1 <= q l <= q 10^9 ) -- the number of messages and the time the user is willing to spend in the messenger. The i -th of the next n lines contains two integers a_i and b_i ( 1 <= a_i, b_i <= 10^9 ) -- characteristics of the i -th message. It is guaranteed that the sum of n^2 over all test cases does not exceed 4 cdot 10^6 . For each test case, output a single integer -- the maximum possible size of a set of messages, the reading time of which does not exceed l . In t"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
249842011 |
Amdadul |
C |
March 5, 2024, 5:50 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
62 |
204800 |
|
|
249840917 |
Imnotndd |
C |
March 5, 2024, 5:42 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
62 |
1740800 |
|
|
249841863 |
Akash_singh11 |
C |
March 5, 2024, 5:49 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
77 |
204800 |
|
|
249838211 |
Imnotndd |
C |
March 5, 2024, 5:26 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
78 |
1740800 |
|
|
249837556 |
crystaalroo |
C |
March 5, 2024, 5:22 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
93 |
102400 |
|
|
249835145 |
vijay4145 |
C |
March 5, 2024, 5:10 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
93 |
204800 |
|
|
249834598 |
sand625 |
C |
March 5, 2024, 5:08 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
93 |
204800 |
|
|
249833902 |
__Morgan |
C |
March 5, 2024, 5:05 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
93 |
204800 |
|
|
249834178 |
Ansh29 |
C |
March 5, 2024, 5:06 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
93 |
80691200 |
|
|
249828119 |
thanglieu |
C |
March 5, 2024, 4:29 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
13 |
108 |
716800 |
|
|
249840130 |
Yuki-JiuCherish |
C |
March 5, 2024, 5:38 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
31 |
132198400 |
|
|
249842710 |
daud04 |
C |
March 5, 2024, 5:54 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
61 |
0 |
|
|
249830232 |
gogo11 |
C |
March 5, 2024, 4:33 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
61 |
102400 |
|
|
249838029 |
TANGhaozhan |
C |
March 5, 2024, 5:25 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
61 |
32153600 |
|
|
249833363 |
Hirro |
C |
March 5, 2024, 5:03 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
62 |
102400 |
|
|
249846667 |
Zeoy_kkk |
C |
March 5, 2024, 6:22 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
14 |
77 |
102400 |
|
|
249833289 |
Inkyo |
C |
March 5, 2024, 5:03 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
77 |
35328000 |
|
|
249834488 |
Gaomer |
C |
March 5, 2024, 5:07 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
93 |
16179200 |
|
|
249837703 |
AhmadSelo |
C |
March 5, 2024, 5:23 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
109 |
102400 |
|
|
249833318 |
dominik-korsa |
C |
March 5, 2024, 5:03 p.m. |
OK |
C++17 (GCC 9-64) |
TESTS |
13 |
139 |
102400 |
|
|
249845706 |
mohaiminul_islam |
C |
March 5, 2024, 6:15 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
0 |
|
|
249838044 |
Firo_SF |
C |
March 5, 2024, 5:25 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
0 |
|
|
249836469 |
Px_102 |
C |
March 5, 2024, 5:16 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
0 |
|
|
249836362 |
F_Rio |
C |
March 5, 2024, 5:16 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
0 |
|
|
249848485 |
nh_nayeem |
C |
March 5, 2024, 6:35 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
20 |
46 |
102400 |
|
|
249848451 |
Sakurama |
C |
March 5, 2024, 6:35 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
20 |
46 |
102400 |
|
|
249837137 |
BowTen |
C |
March 5, 2024, 5:20 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
102400 |
|
|
249836969 |
BowTen |
C |
March 5, 2024, 5:19 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
102400 |
|
|
249834671 |
dqjm |
C |
March 5, 2024, 5:08 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
102400 |
|
|
249832887 |
eemo |
C |
March 5, 2024, 5:02 p.m. |
OK |
C++20 (GCC 11-64) |
TESTS |
13 |
46 |
102400 |
|
|
remove filters
Back to search problems