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"You are playing a game similar to Sokoban on an infinite number line. The game is discrete, so you only consider integer positions on the line. You start on a position 0 . There are n boxes, the i -th box is on a position a_i . All positions of the boxes are distinct. There are also m special positions, the j -th position is b_j . All the special positions are also distinct. In one move you can go one position to the left or to the right. If there is a box in the direction of your move, then you push the box to the next position in that direction. If the next position is taken by another box, then that box is also pushed to the next position, and so on. You can't go through the boxes. You can't pull the boxes towards you. You are allowed to perform any number of moves (possibly, zero). Your goal is to place as many boxes on special positions as possible. Note that some boxes can be initially placed on special positions. The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of testcases. Then descriptions of t testcases follow. The first line of each testcase contains two integers n and m ( 1 <= n, m <= 2 cdot 10^5 ) -- the number of boxes and the number of special positions, respectively. The second line of each testcase contains n distinct integers in the increasing order a_1, a_2, ... , a_n ( -10^9 <= a_1 < a_2 < ... < a_n <= 10^9 ; a_i neq 0 ) -- the initial positions of the boxes. The third line of each testcase contains m distinct integers in the increasing order b_1, b_2, ... , b_m ( -10^9 <= b_1 < b_2 < ... < b_m <= 10^9 ; b_i neq 0 ) -- the special positions. The sum of n over all testcases doesn't exceed 2 cdot 10^5 . The sum of m over all testcases doesn't exceed 2 cdot 10^5 . For each testcase print a single integer -- the maximum number of boxes that can be placed"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
108936948 |
yyyyyyyk |
C |
March 2, 2021, 4:28 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
61 |
3584000 |
|
|
108969095 |
hangyesheng |
C |
March 3, 2021, 2:49 a.m. |
OK |
GNU C++11 |
TESTS |
14 |
61 |
6451200 |
|
|
108965601 |
little_brush |
C |
March 3, 2021, 12:09 a.m. |
OK |
GNU C++11 |
TESTS |
14 |
62 |
3174400 |
|
|
108945867 |
zjjws |
C |
March 2, 2021, 4:51 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
62 |
4096000 |
|
|
108935517 |
Cornflakes |
C |
March 2, 2021, 4:25 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
77 |
17920000 |
|
|
108955809 |
262226781 |
C |
March 2, 2021, 6:50 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
78 |
3788800 |
|
|
108947905 |
ERUIHNIYHBKBNF |
C |
March 2, 2021, 5:08 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
78 |
6451200 |
|
|
108943124 |
snewptl |
C |
March 2, 2021, 4:42 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
93 |
1638400 |
|
|
108970512 |
chickentao |
C |
March 3, 2021, 3:31 a.m. |
OK |
GNU C++11 |
TESTS |
14 |
93 |
2252800 |
|
|
108947513 |
ljjjjjjjq |
C |
March 2, 2021, 5:05 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
93 |
2457600 |
|
|
108941058 |
dlalswp25 |
C |
March 2, 2021, 4:38 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
2457600 |
|
|
108941481 |
Pradhit |
C |
March 2, 2021, 4:39 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
2662400 |
|
|
108961067 |
Tovarisch |
C |
March 2, 2021, 8:38 p.m. |
OK |
GNU C++14 |
TESTS |
14 |
124 |
2969600 |
|
|
108947674 |
KYoA_A |
C |
March 2, 2021, 5:06 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
2969600 |
|
|
108950346 |
meetjoshi |
C |
March 2, 2021, 5:33 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
3174400 |
|
|
108950946 |
volverine |
C |
March 2, 2021, 5:39 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
3174400 |
|
|
108938340 |
MagicaQuartet |
C |
March 2, 2021, 4:32 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
3174400 |
|
|
108945600 |
Chaves |
C |
March 2, 2021, 4:49 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
4300800 |
|
|
108953907 |
Dong_Lee |
C |
March 2, 2021, 6:20 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
4403200 |
|
|
108951278 |
Khaled_Mahmoud |
C |
March 2, 2021, 5:43 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
124 |
4505600 |
|
|
108962707 |
Caustic. |
C |
March 2, 2021, 9:31 p.m. |
OK |
.NET Core C# |
TESTS |
14 |
109 |
18739200 |
|
|
remove filters
Back to search problems