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'Even in kindergarten, Sasha liked a girl. Therefore, he wanted to give her a drawing and attract her attention. As a drawing, he decided to draw a square grid of size n x n , in which some cells are colored. But coloring the cells is difficult, so he wants to color as few cells as possible. But at the same time, he wants at least k diagonals to have at least one colored cell. Note that the square grid of size n x n has a total of 4n - 2 diagonals. Help little Sasha to make the girl fall in love with him and tell him the minimum number of cells he needs to color. Each test consists of multiple test cases. The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of the test cases follows. The only line of each test case contains two integers n and k ( 2 <= q n <= q 10^8 , 1 <= q k <= q 4n - 2 ) -- the size of the square grid and the minimum number of diagonals in which there should be at least one colored cell. For each test case, output a single integer -- the minimum number of cells that need to be colored. In the pictures below, the colored cells are marked in black, and all diagonals are marked in purple. In the first test case, you can color 2 cells so that 4 diagonals contain at least one colored cell: In the third test case, you can color 6 cells so that all 10 diagonals contain at least one colored cell: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
246559745 |
Oikapi |
B |
Feb. 15, 2024, 4:25 p.m. |
OK |
C# 10 |
TESTS |
4 |
62 |
409600 |
|
|
246567996 |
Fomalhaut9918 |
B |
Feb. 15, 2024, 5:07 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
4 |
31 |
0 |
|
|
246599728 |
Soham_ju25 |
B |
Feb. 15, 2024, 10:47 p.m. |
OK |
Clang++20 Diagnostics |
TESTS |
4 |
46 |
0 |
|
|
246560260 |
ar_prosonno |
B |
Feb. 15, 2024, 4:26 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
246557370 |
shimulc17 |
B |
Feb. 15, 2024, 4:19 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
246570825 |
J_A_I_KUMAR |
B |
Feb. 15, 2024, 5:23 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
0 |
|
|
246586077 |
omomgod |
B |
Feb. 15, 2024, 7:33 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246563976 |
Habib_611 |
B |
Feb. 15, 2024, 4:34 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246567622 |
jit10920 |
B |
Feb. 15, 2024, 5:05 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246558833 |
Aryan_234 |
B |
Feb. 15, 2024, 4:22 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246561299 |
Vchiranjeevi9515 |
B |
Feb. 15, 2024, 4:29 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246587917 |
omomgod |
B |
Feb. 15, 2024, 7:54 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246563567 |
White_space6 |
B |
Feb. 15, 2024, 4:34 p.m. |
OK |
GNU C11 |
TESTS |
4 |
15 |
307200 |
|
|
246621063 |
Trigerrr |
B |
Feb. 16, 2024, 5:40 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246620820 |
xhytom |
B |
Feb. 16, 2024, 5:37 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246620818 |
timefliesidont |
B |
Feb. 16, 2024, 5:37 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246620682 |
huehuehue |
B |
Feb. 16, 2024, 5:36 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246622691 |
raw69 |
B |
Feb. 16, 2024, 6 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246622345 |
celestial11 |
B |
Feb. 16, 2024, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246622336 |
KoKoDuDu |
B |
Feb. 16, 2024, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246621841 |
yitien0705 |
B |
Feb. 16, 2024, 5:50 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246621831 |
MAD_N0_1 |
B |
Feb. 16, 2024, 5:50 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246621698 |
GrayJack |
B |
Feb. 16, 2024, 5:48 a.m. |
OK |
GNU C++17 |
TESTS |
4 |
0 |
0 |
|
|
246617003 |
Forbidden_ |
B |
Feb. 16, 2024, 4:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246622064 |
fengjiuge |
B |
Feb. 16, 2024, 5:53 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246621236 |
H_hCoder |
B |
Feb. 16, 2024, 5:42 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246620231 |
SGColin |
B |
Feb. 16, 2024, 5:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246619315 |
666long |
B |
Feb. 16, 2024, 5:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246618552 |
weak100211 |
B |
Feb. 16, 2024, 5:09 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246618255 |
Blame.k |
B |
Feb. 16, 2024, 5:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246617538 |
Wt_vic |
B |
Feb. 16, 2024, 4:55 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246617087 |
801214 |
B |
Feb. 16, 2024, 4:49 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246614252 |
hhhyh |
B |
Feb. 16, 2024, 4:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
4 |
0 |
0 |
|
|
246620144 |
burning_ASH |
B |
Feb. 16, 2024, 5:29 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246620607 |
zyj119 |
B |
Feb. 16, 2024, 5:35 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246621040 |
nikhil6g |
B |
Feb. 16, 2024, 5:40 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246621043 |
AbdulKalam0018 |
B |
Feb. 16, 2024, 5:40 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246621169 |
HTyin |
B |
Feb. 16, 2024, 5:41 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246621619 |
kshitijmgajbhiye |
B |
Feb. 16, 2024, 5:47 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246622235 |
B_a_k_a |
B |
Feb. 16, 2024, 5:55 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246622299 |
Frost_Ice |
B |
Feb. 16, 2024, 5:56 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246622589 |
El-Metador |
B |
Feb. 16, 2024, 5:59 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246622697 |
abdalkreem_bzoor |
B |
Feb. 16, 2024, 6 a.m. |
OK |
GNU C++20 (64) |
TESTS |
4 |
0 |
0 |
|
|
246605049 |
piyush_tanmay |
B |
Feb. 16, 2024, 1:15 a.m. |
OK |
Go |
TESTS |
4 |
15 |
102400 |
|
|
246570992 |
black_rise |
B |
Feb. 15, 2024, 5:24 p.m. |
OK |
Java 21 |
TESTS |
4 |
202 |
0 |
|
|
246594483 |
Nekronishe |
B |
Feb. 15, 2024, 9:15 p.m. |
OK |
Java 21 |
TESTS |
4 |
202 |
102400 |
|
|
246568832 |
ramitg254 |
B |
Feb. 15, 2024, 5:11 p.m. |
OK |
Java 21 |
TESTS |
4 |
202 |
204800 |
|
|
246604186 |
fightingxjz |
B |
Feb. 16, 2024, 12:52 a.m. |
OK |
Java 21 |
TESTS |
4 |
217 |
0 |
|
|
246568744 |
Irvinwop |
B |
Feb. 15, 2024, 5:10 p.m. |
OK |
Java 21 |
TESTS |
4 |
217 |
0 |
|
|
246604178 |
ArcaneA |
B |
Feb. 16, 2024, 12:52 a.m. |
OK |
Java 21 |
TESTS |
4 |
218 |
0 |
|
|
246616985 |
999ms_Clutch |
B |
Feb. 16, 2024, 4:47 a.m. |
OK |
Java 21 |
TESTS |
4 |
218 |
42188800 |
|
|
246570887 |
swatishivam23 |
B |
Feb. 15, 2024, 5:23 p.m. |
OK |
Java 21 |
TESTS |
4 |
233 |
0 |
|
|
246584385 |
dawn_raja |
B |
Feb. 15, 2024, 7:16 p.m. |
OK |
Java 21 |
TESTS |
4 |
249 |
0 |
|
|
246574912 |
Dhruv_savani |
B |
Feb. 15, 2024, 5:53 p.m. |
OK |
Java 21 |
TESTS |
4 |
249 |
0 |
|
|
246606590 |
GaGaxi |
B |
Feb. 16, 2024, 1:48 a.m. |
OK |
Java 8 |
TESTS |
4 |
92 |
0 |
|
|
246608854 |
tirthgohil1410 |
B |
Feb. 16, 2024, 2:34 a.m. |
OK |
Java 8 |
TESTS |
4 |
93 |
0 |
|
|
246581789 |
Required |
B |
Feb. 15, 2024, 6:50 p.m. |
OK |
Java 8 |
TESTS |
4 |
108 |
0 |
|
|
246611394 |
Mr_A |
B |
Feb. 16, 2024, 3:21 a.m. |
OK |
Java 8 |
TESTS |
4 |
124 |
0 |
|
|
246585399 |
Harshit_Jajoo |
B |
Feb. 15, 2024, 7:26 p.m. |
OK |
Java 8 |
TESTS |
4 |
124 |
0 |
|
|
246568845 |
lakshminarayana943 |
B |
Feb. 15, 2024, 5:11 p.m. |
OK |
Java 8 |
TESTS |
4 |
124 |
0 |
|
|
246620011 |
rishitha_b |
B |
Feb. 16, 2024, 5:27 a.m. |
OK |
Java 8 |
TESTS |
4 |
139 |
0 |
|
|
246619730 |
1229050383ZS |
B |
Feb. 16, 2024, 5:23 a.m. |
OK |
Java 8 |
TESTS |
4 |
139 |
0 |
|
|
246589228 |
newlifer |
B |
Feb. 15, 2024, 8:08 p.m. |
OK |
Java 8 |
TESTS |
4 |
139 |
0 |
|
|
246578957 |
Baidiki |
B |
Feb. 15, 2024, 6:24 p.m. |
OK |
Java 8 |
TESTS |
4 |
139 |
0 |
|
|
246621206 |
lemon188 |
B |
Feb. 16, 2024, 5:42 a.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
0 |
0 |
|
|
246621151 |
fww |
B |
Feb. 16, 2024, 5:41 a.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246617043 |
itz_me_priyansh69 |
B |
Feb. 16, 2024, 4:48 a.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246589196 |
6ziv |
B |
Feb. 15, 2024, 8:07 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246587093 |
nitin_choudhary |
B |
Feb. 15, 2024, 7:44 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246563610 |
itsdhruvaggarwal |
B |
Feb. 15, 2024, 4:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246562549 |
SC-Orange-Peel |
B |
Feb. 15, 2024, 4:32 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246561723 |
Sofi_ |
B |
Feb. 15, 2024, 4:30 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246559577 |
mishradivyanshi |
B |
Feb. 15, 2024, 4:24 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246557905 |
CompScientist |
B |
Feb. 15, 2024, 4:20 p.m. |
OK |
MS C++ 2017 |
TESTS |
4 |
15 |
0 |
|
|
246580971 |
Kevin8502 |
B |
Feb. 15, 2024, 6:43 p.m. |
OK |
PHP |
TESTS |
4 |
30 |
0 |
|
|
246591894 |
lebron87 |
B |
Feb. 15, 2024, 8:40 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
109 |
1740800 |
|
|
246592050 |
lebron87 |
B |
Feb. 15, 2024, 8:42 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
109 |
1843200 |
|
|
246590442 |
lebron87 |
B |
Feb. 15, 2024, 8:21 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
124 |
1843200 |
|
|
246562315 |
Elmurat |
B |
Feb. 15, 2024, 4:31 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
140 |
2764800 |
|
|
246580220 |
xpoes |
B |
Feb. 15, 2024, 6:35 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2764800 |
|
|
246594665 |
Bluefog99 |
B |
Feb. 15, 2024, 9:18 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
155 |
2969600 |
|
|
246593398 |
nealzane |
B |
Feb. 15, 2024, 9 p.m. |
OK |
PyPy 3 |
TESTS |
4 |
202 |
5222400 |
|
|
246591601 |
gardengnome |
B |
Feb. 15, 2024, 8:36 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
46 |
0 |
|
|
246620676 |
ProCoder12 |
B |
Feb. 16, 2024, 5:36 a.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
62 |
1843200 |
|
|
246582423 |
Pronoy_Deb |
B |
Feb. 15, 2024, 6:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
62 |
1843200 |
|
|
246557531 |
little_young |
B |
Feb. 15, 2024, 4:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
62 |
2252800 |
|
|
246565742 |
InHng |
B |
Feb. 15, 2024, 4:57 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
77 |
1638400 |
|
|
246575066 |
Mohamed_Hamed |
B |
Feb. 15, 2024, 5:54 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
77 |
1843200 |
|
|
246576528 |
RobinFromTheHood |
B |
Feb. 15, 2024, 6:05 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
77 |
2457600 |
|
|
246622391 |
cybsbbb |
B |
Feb. 16, 2024, 5:57 a.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
77 |
2662400 |
|
|
246588131 |
Deecey01 |
B |
Feb. 15, 2024, 7:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
77 |
2662400 |
|
|
246584354 |
abenezer_m54 |
B |
Feb. 15, 2024, 7:15 p.m. |
OK |
PyPy 3-64 |
TESTS |
4 |
77 |
2662400 |
|
|
246566307 |
OLOGY |
B |
Feb. 15, 2024, 4:58 p.m. |
OK |
Python 2 |
TESTS |
4 |
30 |
0 |
|
|
246568476 |
OLOGY |
B |
Feb. 15, 2024, 5:09 p.m. |
OK |
Python 2 |
TESTS |
4 |
46 |
0 |
|
|
246620710 |
ProCoder12 |
B |
Feb. 16, 2024, 5:36 a.m. |
OK |
Python 3 |
TESTS |
4 |
30 |
0 |
|
|
246597543 |
amir2079 |
B |
Feb. 15, 2024, 10:01 p.m. |
OK |
Python 3 |
TESTS |
4 |
30 |
0 |
|
|
246592124 |
ANTH4RAX |
B |
Feb. 15, 2024, 8:43 p.m. |
OK |
Python 3 |
TESTS |
4 |
30 |
0 |
|
|
246565843 |
Samyak_15 |
B |
Feb. 15, 2024, 4:57 p.m. |
OK |
Python 3 |
TESTS |
4 |
30 |
0 |
|
|
246620877 |
klu2100032365 |
B |
Feb. 16, 2024, 5:38 a.m. |
OK |
Python 3 |
TESTS |
4 |
31 |
0 |
|
|
246616322 |
M4qa1 |
B |
Feb. 16, 2024, 4:38 a.m. |
OK |
Python 3 |
TESTS |
4 |
31 |
0 |
|
|
246607901 |
ryuuichi_ |
B |
Feb. 16, 2024, 2:14 a.m. |
OK |
Python 3 |
TESTS |
4 |
31 |
0 |
|
|
246606606 |
Jawad_Kaleem |
B |
Feb. 16, 2024, 1:48 a.m. |
OK |
Python 3 |
TESTS |
4 |
31 |
0 |
|
|
246604624 |
VioletVal |
B |
Feb. 16, 2024, 1:04 a.m. |
OK |
Python 3 |
TESTS |
4 |
31 |
0 |
|
|
246584218 |
Asmaa_Elsayed |
B |
Feb. 15, 2024, 7:14 p.m. |
OK |
Python 3 |
TESTS |
4 |
31 |
0 |
|
|
246558029 |
sabbirahmeds877 |
B |
Feb. 15, 2024, 4:20 p.m. |
OK |
Ruby 3 |
TESTS |
4 |
374 |
102400 |
|
|
246582337 |
0x81 |
B |
Feb. 15, 2024, 6:55 p.m. |
OK |
Ruby 3 |
TESTS |
4 |
420 |
614400 |
|
|
246610116 |
BobChuckyJoe |
B |
Feb. 16, 2024, 2:59 a.m. |
OK |
Rust 2021 |
TESTS |
4 |
15 |
0 |
|
|
246571180 |
vstiff |
B |
Feb. 15, 2024, 5:25 p.m. |
OK |
Rust 2021 |
TESTS |
4 |
15 |
0 |
|
|
246568912 |
Chalaghoram |
B |
Feb. 15, 2024, 5:11 p.m. |
OK |
Rust 2021 |
TESTS |
4 |
15 |
0 |
|
|
246560326 |
jhonyn |
B |
Feb. 15, 2024, 4:26 p.m. |
OK |
Rust 2021 |
TESTS |
4 |
15 |
0 |
|
|
remove filters
Back to search problems