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 the author of a Codeforces round and have prepared n problems you are going to set, problem i having difficulty a_i . You will do the following process: A round is considered balanced if and only if the absolute difference between the difficulty of any two consecutive problems is at most k (less or equal than k ). What is the minimum number of problems you have to remove so that an arrangement of problems is balanced? The first line contains a single integer t ( 1 <= q t <= q 1000 ) -- the number of test cases. The first line of each test case contains two positive integers n ( 1 <= q n <= q 2 cdot 10^5 ) and k ( 1 <= q k <= q 10^9 ) -- the number of problems, and the maximum allowed absolute difference between consecutive problems. The second line of each test case contains n space-separated integers a_i ( 1 <= q a_i <= q 10^9 ) -- the difficulty of each problem. Note that the sum of n over all test cases doesn't exceed 2 cdot 10^5 . For each test case, output a single integer -- the minimum number of problems you have to remove so that an arrangement of problems is balanced. For the first test case, we can remove the first 2 problems and construct a set using problems with the difficulties [4, 5, 6] , with difficulties between adjacent problems equal to |5 - 4| = 1 <= q 1 and |6 - 5| = 1 <= q 1 . For the second test case, we can take the single problem and compose a round using the problem with difficulty 10 . "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
215071934 |
serj.planet1 |
D |
July 22, 2023, 4:16 p.m. |
OK |
C# 10 |
TESTS |
18 |
93 |
19251200 |
|
|
215092536 |
Aditya9430 |
D |
July 22, 2023, 7:05 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
18 |
1076 |
819200 |
|
|
215100062 |
veerX01 |
D |
July 22, 2023, 8:34 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
18 |
1107 |
22016000 |
|
|
215023292 |
NenadDapic |
D |
July 22, 2023, 9:22 a.m. |
OK |
FPC |
TESTS |
18 |
77 |
1638400 |
|
|
215079741 |
Md-Dipu |
D |
July 22, 2023, 5:12 p.m. |
OK |
GNU C11 |
TESTS |
18 |
77 |
819200 |
|
|
215052790 |
Ahmed_Esmail |
D |
July 22, 2023, 2:05 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
61 |
2457600 |
|
|
215124638 |
nitvjudge1 |
D |
July 23, 2023, 4:38 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215123439 |
Chenyuli_ |
D |
July 23, 2023, 4:15 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215123383 |
Chenyuli_ |
D |
July 23, 2023, 4:14 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215116367 |
3.14159265359 |
D |
July 23, 2023, 2:09 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215114263 |
zheng_di1132 |
D |
July 23, 2023, 1:28 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215107877 |
Nyemot |
D |
July 22, 2023, 10:52 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215094605 |
nisthasinghindore |
D |
July 22, 2023, 7:26 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215086920 |
xodeChemist |
D |
July 22, 2023, 6:11 p.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215126639 |
Lihg |
D |
July 23, 2023, 5:13 a.m. |
OK |
GNU C++14 |
TESTS |
18 |
62 |
819200 |
|
|
215127375 |
D_O_N_A_T_I_L_O |
D |
July 23, 2023, 5:23 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215124965 |
jack_ryan |
D |
July 23, 2023, 4:44 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215124725 |
Ywave |
D |
July 23, 2023, 4:39 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215112580 |
MarslinoEdward |
D |
July 23, 2023, 12:52 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215111711 |
Hainf |
D |
July 23, 2023, 12:29 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215105630 |
ahmad_baker |
D |
July 22, 2023, 9:59 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215101727 |
MinaMagdy1 |
D |
July 22, 2023, 8:57 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215093693 |
execute15 |
D |
July 22, 2023, 7:17 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215093265 |
joshd |
D |
July 22, 2023, 7:13 p.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215128209 |
Harmony666 |
D |
July 23, 2023, 5:35 a.m. |
OK |
GNU C++17 |
TESTS |
18 |
62 |
819200 |
|
|
215023751 |
Uchiha_Itachi25 |
D |
July 22, 2023, 9:25 a.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215101456 |
Esraa.m |
D |
July 22, 2023, 8:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215089604 |
shuvocoder2025 |
D |
July 22, 2023, 6:35 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215088421 |
Vax |
D |
July 22, 2023, 6:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215063436 |
Mahmuda.B |
D |
July 22, 2023, 3:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215014602 |
bkifhr8 |
D |
July 22, 2023, 8:14 a.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215062931 |
zhengshurui0627 |
D |
July 22, 2023, 3:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
1638400 |
|
|
215084805 |
Leoknowstheway |
D |
July 22, 2023, 5:54 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
1638400 |
|
|
215021887 |
shreyashkatkar04 |
D |
July 22, 2023, 9:11 a.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
2150400 |
|
|
215091121 |
sanchit.chaba |
D |
July 22, 2023, 6:49 p.m. |
OK |
GNU C++17 (64) |
TESTS |
18 |
46 |
5836800 |
|
|
215111870 |
luogu_bot4 |
D |
July 23, 2023, 12:33 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
31 |
819200 |
|
|
215122853 |
_Dusker |
D |
July 23, 2023, 4:03 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215122377 |
buaa_czx |
D |
July 23, 2023, 3:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215122343 |
buaa_czx |
D |
July 23, 2023, 3:54 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215122285 |
radhe_radhe__ |
D |
July 23, 2023, 3:52 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215121878 |
hustler221071 |
D |
July 23, 2023, 3:45 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215121112 |
drevz |
D |
July 23, 2023, 3:31 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215119996 |
Tang7777777 |
D |
July 23, 2023, 3:13 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215119495 |
Kyzer1de |
D |
July 23, 2023, 3:04 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215123400 |
Jil_Patel |
D |
July 23, 2023, 4:14 a.m. |
OK |
GNU C++20 (64) |
TESTS |
18 |
46 |
819200 |
|
|
215097556 |
shisanyue |
D |
July 22, 2023, 8:02 p.m. |
OK |
Go |
TESTS |
18 |
140 |
4710400 |
|
|
215059737 |
Dull |
D |
July 22, 2023, 2:55 p.m. |
OK |
Go |
TESTS |
18 |
140 |
4710400 |
|
|
215072609 |
TJ_Codes |
D |
July 22, 2023, 4:21 p.m. |
OK |
Java 11 |
TESTS |
18 |
249 |
0 |
|
|
215061926 |
pakkapapad |
D |
July 22, 2023, 3:10 p.m. |
OK |
Java 11 |
TESTS |
18 |
249 |
0 |
|
|
215052179 |
Siyaram_13 |
D |
July 22, 2023, 2:01 p.m. |
OK |
Java 11 |
TESTS |
18 |
280 |
716800 |
|
|
215048831 |
minibin |
D |
July 22, 2023, 1:37 p.m. |
OK |
Java 11 |
TESTS |
18 |
295 |
0 |
|
|
215090325 |
IceWolf898 |
D |
July 22, 2023, 6:41 p.m. |
OK |
Java 11 |
TESTS |
18 |
296 |
102400 |
|
|
215050285 |
ananya_s_s |
D |
July 22, 2023, 1:47 p.m. |
OK |
Java 11 |
TESTS |
18 |
296 |
7372800 |
|
|
215023901 |
ananya_s_s |
D |
July 22, 2023, 9:26 a.m. |
OK |
Java 11 |
TESTS |
18 |
296 |
7372800 |
|
|
215075627 |
sambhav19329 |
D |
July 22, 2023, 4:42 p.m. |
OK |
Java 11 |
TESTS |
18 |
498 |
2560000 |
|
|
215024145 |
saoodahmad |
D |
July 22, 2023, 9:28 a.m. |
OK |
Java 11 |
TESTS |
18 |
545 |
2560000 |
|
|
215118596 |
ahmed_aly33 |
D |
July 23, 2023, 2:48 a.m. |
OK |
Java 11 |
TESTS |
18 |
545 |
13721600 |
|
|
215014604 |
coder0687 |
D |
July 22, 2023, 8:14 a.m. |
OK |
Java 17 |
TESTS |
18 |
218 |
716800 |
|
|
215064346 |
Vrutik_2809 |
D |
July 22, 2023, 3:26 p.m. |
OK |
Java 17 |
TESTS |
18 |
218 |
716800 |
|
|
215115028 |
ShresCodes |
D |
July 23, 2023, 1:43 a.m. |
OK |
Java 17 |
TESTS |
18 |
249 |
614400 |
|
|
215050175 |
tbs-jyy |
D |
July 22, 2023, 1:46 p.m. |
OK |
Java 17 |
TESTS |
18 |
264 |
614400 |
|
|
215049820 |
ashutoshchahar1250 |
D |
July 22, 2023, 1:43 p.m. |
OK |
Java 17 |
TESTS |
18 |
265 |
512000 |
|
|
215075610 |
iamdimonis |
D |
July 22, 2023, 4:42 p.m. |
OK |
Java 17 |
TESTS |
18 |
265 |
716800 |
|
|
215056017 |
ADust |
D |
July 22, 2023, 2:29 p.m. |
OK |
Java 17 |
TESTS |
18 |
265 |
1228800 |
|
|
215022977 |
Sinzy |
D |
July 22, 2023, 9:19 a.m. |
OK |
Java 17 |
TESTS |
18 |
295 |
21708800 |
|
|
215079971 |
Suraj1607 |
D |
July 22, 2023, 5:14 p.m. |
OK |
Java 17 |
TESTS |
18 |
296 |
512000 |
|
|
215073712 |
Just4Fun_ |
D |
July 22, 2023, 4:28 p.m. |
OK |
Java 17 |
TESTS |
18 |
296 |
1228800 |
|
|
215052963 |
SilveryZz |
D |
July 22, 2023, 2:06 p.m. |
OK |
Java 8 |
TESTS |
18 |
155 |
3072000 |
|
|
215022148 |
SilveryZz |
D |
July 22, 2023, 9:13 a.m. |
OK |
Java 8 |
TESTS |
18 |
155 |
3072000 |
|
|
215027273 |
Harshit_3905 |
D |
July 22, 2023, 9:57 a.m. |
OK |
Java 8 |
TESTS |
18 |
171 |
3072000 |
|
|
215022008 |
SilveryZz |
D |
July 22, 2023, 9:12 a.m. |
OK |
Java 8 |
TESTS |
18 |
171 |
3072000 |
|
|
215066558 |
roeyr102 |
D |
July 22, 2023, 3:41 p.m. |
OK |
Java 8 |
TESTS |
18 |
202 |
0 |
|
|
215067295 |
vijay_panwar12 |
D |
July 22, 2023, 3:46 p.m. |
OK |
Java 8 |
TESTS |
18 |
202 |
3788800 |
|
|
215086989 |
complexorigin |
D |
July 22, 2023, 6:12 p.m. |
OK |
Java 8 |
TESTS |
18 |
202 |
3891200 |
|
|
215078947 |
mena_maherr |
D |
July 22, 2023, 5:06 p.m. |
OK |
Java 8 |
TESTS |
18 |
202 |
4096000 |
|
|
215092675 |
dogranmol |
D |
July 22, 2023, 7:06 p.m. |
OK |
Java 8 |
TESTS |
18 |
218 |
3788800 |
|
|
215090137 |
IceWolf898 |
D |
July 22, 2023, 6:39 p.m. |
OK |
Java 8 |
TESTS |
18 |
218 |
4505600 |
|
|
215024301 |
Krantzy |
D |
July 22, 2023, 9:29 a.m. |
OK |
Kotlin 1.7 |
TESTS |
18 |
810 |
76697600 |
|
|
215123684 |
MengXn |
D |
July 23, 2023, 4:20 a.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
187 |
819200 |
|
|
215116679 |
napatnicky |
D |
July 23, 2023, 2:15 a.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
202 |
819200 |
|
|
215084745 |
abdo663 |
D |
July 22, 2023, 5:53 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
202 |
819200 |
|
|
215119777 |
lirejie |
D |
July 23, 2023, 3:09 a.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
218 |
819200 |
|
|
215118763 |
qingweiliao |
D |
July 23, 2023, 2:52 a.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
218 |
1638400 |
|
|
215102204 |
Abdullah_Mahmoud |
D |
July 22, 2023, 9:05 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
218 |
2252800 |
|
|
215094717 |
mj2003 |
D |
July 22, 2023, 7:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
234 |
3072000 |
|
|
215118996 |
NguyenVanNgocHuy |
D |
July 23, 2023, 2:56 a.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
265 |
3276800 |
|
|
215068967 |
zjnT04 |
D |
July 22, 2023, 3:57 p.m. |
OK |
MS C++ 2017 |
TESTS |
18 |
327 |
20992000 |
|
|
215089070 |
rasheed_ashen_one |
D |
July 22, 2023, 6:29 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
280 |
19046400 |
|
|
215082549 |
Heldash |
D |
July 22, 2023, 5:35 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
296 |
19046400 |
|
|
215024623 |
lol_py |
D |
July 22, 2023, 9:32 a.m. |
OK |
PyPy 3 |
TESTS |
18 |
296 |
19046400 |
|
|
215051168 |
urparvezali |
D |
July 22, 2023, 1:53 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
311 |
19251200 |
|
|
215102956 |
abhay_codes |
D |
July 22, 2023, 9:17 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
326 |
19558400 |
|
|
215051412 |
_0Istahak |
D |
July 22, 2023, 1:55 p.m. |
OK |
PyPy 3 |
TESTS |
18 |
327 |
19046400 |
|
|
215013464 |
uz2ee |
D |
July 22, 2023, 8:07 a.m. |
OK |
PyPy 3 |
TESTS |
18 |
327 |
19046400 |
|
|
215023228 |
ArtemMB |
D |
July 22, 2023, 9:21 a.m. |
OK |
PyPy 3 |
TESTS |
18 |
327 |
19763200 |
|
|
215108280 |
RussDT |
D |
July 22, 2023, 11 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
124 |
30105600 |
|
|
215060769 |
eternal_happiness |
D |
July 22, 2023, 3:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
124 |
30105600 |
|
|
215108277 |
Quiche |
D |
July 22, 2023, 11 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
139 |
21299200 |
|
|
215064228 |
dotaror |
D |
July 22, 2023, 3:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
139 |
27545600 |
|
|
215063505 |
kmmemon05 |
D |
July 22, 2023, 3:20 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
139 |
27545600 |
|
|
215104400 |
Mofh |
D |
July 22, 2023, 9:38 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
140 |
21401600 |
|
|
215116802 |
jamerrq |
D |
July 23, 2023, 2:17 a.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
140 |
27545600 |
|
|
215081818 |
Eeezoe |
D |
July 22, 2023, 5:29 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
140 |
27545600 |
|
|
215062436 |
AyuAnchor |
D |
July 22, 2023, 3:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
140 |
27545600 |
|
|
215052561 |
Prasad.Naidu_9 |
D |
July 22, 2023, 2:03 p.m. |
OK |
PyPy 3-64 |
TESTS |
18 |
140 |
27545600 |
|
|
215013782 |
dazlersan1 |
D |
July 22, 2023, 8:09 a.m. |
OK |
Python 3 |
TESTS |
18 |
171 |
27955200 |
|
|
215068976 |
jalapathisharathchandra |
D |
July 22, 2023, 3:57 p.m. |
OK |
Python 3 |
TESTS |
18 |
171 |
28672000 |
|
|
215052298 |
mALPANIpRANJUL |
D |
July 22, 2023, 2:02 p.m. |
OK |
Python 3 |
TESTS |
18 |
186 |
26521600 |
|
|
215109209 |
amanueltsehay11 |
D |
July 22, 2023, 11:23 p.m. |
OK |
Python 3 |
TESTS |
18 |
186 |
27955200 |
|
|
215048700 |
Tan_K |
D |
July 22, 2023, 1:36 p.m. |
OK |
Python 3 |
TESTS |
18 |
186 |
28672000 |
|
|
215024627 |
abhishek229 |
D |
July 22, 2023, 9:32 a.m. |
OK |
Python 3 |
TESTS |
18 |
186 |
28672000 |
|
|
215024872 |
21wh1a05h9 |
D |
July 22, 2023, 9:34 a.m. |
OK |
Python 3 |
TESTS |
18 |
187 |
27852800 |
|
|
215082746 |
-BOOGEYMAN- |
D |
July 22, 2023, 5:37 p.m. |
OK |
Python 3 |
TESTS |
18 |
187 |
28467200 |
|
|
215122808 |
chnaveen |
D |
July 23, 2023, 4:03 a.m. |
OK |
Python 3 |
TESTS |
18 |
187 |
28672000 |
|
|
215021658 |
liquid_int |
D |
July 22, 2023, 9:10 a.m. |
OK |
Python 3 |
TESTS |
18 |
187 |
28672000 |
|
|
215108820 |
lucbarn |
D |
July 22, 2023, 11:14 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
31 |
7884800 |
|
|
215068491 |
ilyshana |
D |
July 22, 2023, 3:54 p.m. |
OK |
Rust 2021 |
TESTS |
18 |
31 |
7884800 |
|
|
remove filters
Back to search problems