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"There is a square matrix, consisting of n rows and n columns of cells, both numbered from 1 to n . The cells are colored white or black. Cells from 1 to a_i are black, and cells from a_i+1 to n are white, in the i -th column. You want to place m integers in the matrix, from 1 to m . There are two rules: The beauty of the matrix is the number of such j that j+1 is written in the same row, in the next column as j (in the neighbouring cell to the right). What's the maximum possible beauty of the matrix? The first line contains a single integer t ( 1 <= t <= 10^4 ) -- the number of testcases. The first line of each testcase contains a single integer n ( 1 <= n <= 2 cdot 10^5 ) -- the size of the matrix. The second line contains n integers a_1, a_2, ... , a_n ( 0 <= a_i <= n ) -- the number of black cells in each column. The third line contains a single integer m ( 0 <= m <= sum limits_{i=1}^n n - a_i ) -- the number of integers you have to write in the matrix. Note that this number might not fit into a 32-bit integer data type. The sum of n over all testcases doesn't exceed 2 cdot 10^5 . For each testcase, print a single integer -- the maximum beauty of the matrix after you write all m integers in it. Note that there are no more integers than the white cells, so the answer always exists. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
209475512 |
Tdyx |
E |
June 12, 2023, 4:51 p.m. |
OK |
C# 10 |
TESTS |
53 |
124 |
36044800 |
|
|
209508355 |
PYD |
E |
June 13, 2023, 2:02 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
109 |
10649600 |
|
|
209516880 |
Sanjay422 |
E |
June 13, 2023, 4:29 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
109 |
13312000 |
|
|
209498477 |
sakurasonic |
E |
June 12, 2023, 9:19 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
124 |
9625600 |
|
|
209511034 |
CCCCOrz |
E |
June 13, 2023, 2:46 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
140 |
13516800 |
|
|
209509273 |
iamcclocation |
E |
June 13, 2023, 2:18 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
155 |
144486400 |
|
|
209507104 |
KING_OF_TURTLE |
E |
June 13, 2023, 1:38 a.m. |
OK |
GNU C++14 |
TESTS |
53 |
156 |
43315200 |
|
|
209472303 |
carnation13 |
E |
June 12, 2023, 4:36 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
171 |
68300800 |
|
|
209491195 |
omeganot |
E |
June 12, 2023, 7:17 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
218 |
7475200 |
|
|
209482416 |
karanaggarwal |
E |
June 12, 2023, 5:44 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
218 |
17612800 |
|
|
209503689 |
_chuoi_ |
E |
June 12, 2023, 11:57 p.m. |
OK |
GNU C++14 |
TESTS |
53 |
248 |
14131200 |
|
|
209485476 |
Tinky-Winky |
E |
June 12, 2023, 6:14 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
77 |
14336000 |
|
|
209510760 |
Gr47 |
E |
June 13, 2023, 2:41 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
93 |
17203200 |
|
|
209494244 |
dumb_boi |
E |
June 12, 2023, 8:01 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
108 |
12185600 |
|
|
209475718 |
lxyb |
E |
June 12, 2023, 4:52 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
108 |
24985600 |
|
|
209511118 |
Gr47 |
E |
June 13, 2023, 2:47 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
109 |
17203200 |
|
|
209506354 |
MarioYC |
E |
June 13, 2023, 1:19 a.m. |
OK |
GNU C++17 |
TESTS |
53 |
109 |
32870400 |
|
|
209470512 |
Cui_Luan |
E |
June 12, 2023, 4:32 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
124 |
13516800 |
|
|
209484144 |
Scalm |
E |
June 12, 2023, 6:01 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
124 |
16588800 |
|
|
209500189 |
kondasujay2 |
E |
June 12, 2023, 9:59 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
124 |
17817600 |
|
|
209479545 |
lucasturci |
E |
June 12, 2023, 5:18 p.m. |
OK |
GNU C++17 |
TESTS |
53 |
139 |
31744000 |
|
|
209472950 |
HpSuda |
E |
June 12, 2023, 4:38 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
46 |
2457600 |
|
|
209496766 |
placik |
E |
June 12, 2023, 8:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
61 |
6553600 |
|
|
209516285 |
chappy1 |
E |
June 13, 2023, 4:18 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
62 |
3993600 |
|
|
209477912 |
_chroneZ |
E |
June 12, 2023, 5:06 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
62 |
3993600 |
|
|
209517066 |
Bruteforcer101 |
E |
June 13, 2023, 4:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
62 |
6553600 |
|
|
209516411 |
Alex_Wei |
E |
June 13, 2023, 4:20 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
62 |
25088000 |
|
|
209469799 |
Kude |
E |
June 12, 2023, 4:31 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
77 |
9523200 |
|
|
209503941 |
Alex_Wei |
E |
June 13, 2023, 12:05 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
78 |
18329600 |
|
|
209470880 |
_zay |
E |
June 12, 2023, 4:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
93 |
22220800 |
|
|
209505857 |
gqf123 |
E |
June 13, 2023, 1:07 a.m. |
OK |
GNU C++17 (64) |
TESTS |
53 |
186 |
16076800 |
|
|
209504548 |
A_G |
E |
June 13, 2023, 12:26 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
3276800 |
|
|
209519307 |
bao_zi7 |
E |
June 13, 2023, 5:16 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
6860800 |
|
|
209510643 |
Liuf |
E |
June 13, 2023, 2:39 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
6860800 |
|
|
209478874 |
phoenix0423 |
E |
June 12, 2023, 5:13 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
6860800 |
|
|
209483133 |
QAQ.Maple |
E |
June 12, 2023, 5:51 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
7475200 |
|
|
209505684 |
Misono_Mika |
E |
June 13, 2023, 1:02 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
7884800 |
|
|
209511786 |
zbceyond |
E |
June 13, 2023, 3 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
10649600 |
|
|
209503786 |
Sanam007 |
E |
June 13, 2023, midnight |
OK |
GNU C++20 (64) |
TESTS |
53 |
46 |
11673600 |
|
|
209514068 |
arodnap33 |
E |
June 13, 2023, 3:41 a.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
62 |
4096000 |
|
|
209485070 |
vgtcross |
E |
June 12, 2023, 6:10 p.m. |
OK |
GNU C++20 (64) |
TESTS |
53 |
62 |
5836800 |
|
|
209519985 |
0x3F |
E |
June 13, 2023, 5:26 a.m. |
OK |
Go |
TESTS |
53 |
343 |
23040000 |
|
|
209519394 |
0x3F |
E |
June 13, 2023, 5:17 a.m. |
OK |
Go |
TESTS |
53 |
421 |
23142400 |
|
|
209470432 |
profchi |
E |
June 12, 2023, 4:32 p.m. |
OK |
Java 11 |
TESTS |
53 |
935 |
24166400 |
|
|
209517688 |
klu2100031997 |
E |
June 13, 2023, 4:42 a.m. |
OK |
Java 17 |
TESTS |
53 |
654 |
15155200 |
|
|
209497973 |
xuhao95 |
E |
June 12, 2023, 9:07 p.m. |
OK |
PyPy 3 |
TESTS |
53 |
764 |
45772800 |
|
|
209521816 |
1_2_3_4_5_9 |
E |
June 13, 2023, 5:51 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
233 |
57344000 |
|
|
209475806 |
misorin |
E |
June 12, 2023, 4:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
389 |
32563200 |
|
|
209510139 |
SoleProprietor |
E |
June 13, 2023, 2:32 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
483 |
28467200 |
|
|
209502688 |
alxwen711 |
E |
June 12, 2023, 11:20 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
639 |
47718400 |
|
|
209497982 |
xuhao95 |
E |
June 12, 2023, 9:08 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
701 |
67788800 |
|
|
209515701 |
tassei903 |
E |
June 13, 2023, 4:08 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
763 |
53760000 |
|
|
209476660 |
Mukundan314 |
E |
June 12, 2023, 4:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
764 |
73523200 |
|
|
209507036 |
liupengsay |
E |
June 13, 2023, 1:36 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
764 |
100659200 |
|
|
209513846 |
xxh1999 |
E |
June 13, 2023, 3:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
982 |
46592000 |
|
|
209517171 |
Little_Sheep_Yawn |
E |
June 13, 2023, 4:34 a.m. |
OK |
PyPy 3-64 |
TESTS |
53 |
1169 |
60313600 |
|
|
209485417 |
YummyPie |
E |
June 12, 2023, 6:13 p.m. |
OK |
Rust 2021 |
TESTS |
53 |
31 |
12697600 |
|
|
remove filters
Back to search problems