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 have an array a of n elements. There are also q modifications of the array. Before the first modification and after each modification, you would like to know the following: What is the minimum length subarray that needs to be sorted in non-decreasing order in order for the array a to be completely sorted in non-decreasing order? More formally, you want to select a subarray of the array (l, r) with the minimum value of r - l + 1 . After that, you will sort the elements a_{l}, a_{l + 1}, ldots, a_{r} and want the condition a_{i} <= a_{i + 1} to hold for all 1 <= i < n . If the array is already sorted in non-decreasing order, then l and r should be considered as equal to -1 . Note that finding such (l, r) does not change the array in any way. The modifications themselves take the form: assign a_{pos} = x for given pos and x . Each test consists of several test cases. The first line contains an integer t ( 1 <= t <= 10 ) -- the number of test cases. Then follows the description of test cases. The first line of each test case contains a single integer n ( 1 <= n <= 5 cdot 10^{5} ). The second line of each test case contains n integers a_{i} ( 0 <= |a_{i}| <= 10^{9} ) -- the initial elements of the array a . The third line of each test case contains a number q ( 0 <= q <= 5 cdot 10^{5} ) -- the number of modifications to the array. The following q lines of each test case contain two integers pos_{i} ( 1 <= pos_{i} <= n ) and val_{i} ( 0 <= |val_{i}| <= 10^{9} ) -- this means that for the i -th modification, a_{pos_{i}} is assigned the value val_{i} . It is guaranteed that the sum of n and the sum of q for all test cases does not exceed 5 cdot 10^{5} . For each test case, output q + 1 lines. Each line should contain 2 integ'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
267404783 |
Reanap |
F |
June 25, 2024, 4:34 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
984 |
26112000 |
|
|
267439655 |
lsxhyyds |
F |
June 25, 2024, 10:44 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1031 |
20070400 |
|
|
267452464 |
CRJ_ZCR |
F |
June 26, 2024, 3:13 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1124 |
31129600 |
|
|
267452308 |
CRJ_ZCR |
F |
June 26, 2024, 3:11 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1156 |
31129600 |
|
|
267452531 |
CRJ_ZCR |
F |
June 26, 2024, 3:14 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1202 |
31232000 |
|
|
267402058 |
RIGC |
F |
June 25, 2024, 4:29 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1249 |
31232000 |
|
|
267465351 |
sunumbrella |
F |
June 26, 2024, 5:41 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
38 |
1312 |
31129600 |
|
|
267452118 |
HHH666666 |
F |
June 26, 2024, 3:07 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1374 |
40140800 |
|
|
267446633 |
Junz_LJL |
F |
June 26, 2024, 1:27 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1765 |
88166400 |
|
|
267458254 |
4977 |
F |
June 26, 2024, 4:28 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
36 |
1968 |
130252800 |
|
|
267449530 |
cutx86 |
F |
June 26, 2024, 2:25 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
687 |
26112000 |
|
|
267439064 |
afjskdlfjafkj |
F |
June 25, 2024, 10:32 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
702 |
42086400 |
|
|
267452543 |
Sempr |
F |
June 26, 2024, 3:14 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
952 |
32153600 |
|
|
267418948 |
_user_ |
F |
June 25, 2024, 6:22 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
952 |
48435200 |
|
|
267465551 |
sanjay.garg2072 |
F |
June 26, 2024, 5:42 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
38 |
983 |
23142400 |
|
|
267439045 |
afjskdlfjafkj |
F |
June 25, 2024, 10:31 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
1015 |
84172800 |
|
|
267446932 |
Tobo |
F |
June 26, 2024, 1:34 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
1031 |
31232000 |
|
|
267457315 |
nhuhieu193 |
F |
June 26, 2024, 4:17 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
1062 |
22016000 |
|
|
267417831 |
amcbn |
F |
June 25, 2024, 6:13 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
1062 |
31232000 |
|
|
267408501 |
Alpha_Q |
F |
June 25, 2024, 5:15 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
36 |
1077 |
23142400 |
|
|
267417291 |
neal |
F |
June 25, 2024, 6:09 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
281 |
12800000 |
|
|
267443138 |
CLT |
F |
June 26, 2024, 12:08 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
453 |
24166400 |
|
|
267449211 |
CC2021zyz |
F |
June 26, 2024, 2:19 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
467 |
44236800 |
|
|
267451251 |
ZrjaK |
F |
June 26, 2024, 2:53 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
546 |
32972800 |
|
|
267411207 |
CTHOOH |
F |
June 25, 2024, 5:29 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
561 |
26112000 |
|
|
267458313 |
camc |
F |
June 26, 2024, 4:28 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
593 |
16384000 |
|
|
267439073 |
afjskdlfjafkj |
F |
June 25, 2024, 10:32 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
655 |
42086400 |
|
|
267455871 |
Zinc-acetate |
F |
June 26, 2024, 4:01 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
671 |
21606400 |
|
|
267459668 |
weirdflexbutok |
F |
June 26, 2024, 4:43 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
671 |
34304000 |
|
|
267404947 |
Andreasyan |
F |
June 25, 2024, 4:34 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
36 |
671 |
50176000 |
|
|
267419709 |
cry |
F |
June 25, 2024, 6:28 p.m. |
OK |
Java 21 |
TESTS |
36 |
2374 |
126361600 |
|
|
267408104 |
omeganot |
F |
June 25, 2024, 5:14 p.m. |
OK |
Java 8 |
TESTS |
36 |
2046 |
80179200 |
|
|
267419552 |
misorin |
F |
June 25, 2024, 6:27 p.m. |
OK |
PyPy 3-64 |
TESTS |
36 |
1655 |
126361600 |
|
|
267424624 |
misorin |
F |
June 25, 2024, 7:11 p.m. |
OK |
PyPy 3-64 |
TESTS |
36 |
1827 |
186265600 |
|
|
267417194 |
misorin |
F |
June 25, 2024, 6:08 p.m. |
OK |
PyPy 3-64 |
TESTS |
36 |
2202 |
135782400 |
|
|
267412565 |
toor |
F |
June 25, 2024, 5:37 p.m. |
OK |
Rust 2021 |
TESTS |
36 |
592 |
18124800 |
|
|
267414934 |
kost |
F |
June 25, 2024, 5:52 p.m. |
OK |
Rust 2021 |
TESTS |
36 |
717 |
42803200 |
|
|
267435656 |
lrvideckis |
F |
June 25, 2024, 9:29 p.m. |
OK |
Rust 2021 |
TESTS |
36 |
2030 |
34816000 |
|
|
remove filters
Back to search problems