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
Note the unusual memory limit. Silver Wolf gives you an array (a) of length (n) and (q) queries. In each query, she replaces an element in (a). After each query, she asks you to output the maximum integer (k) such that there exists an integer (x) such that it is the (k)-majority of a subarray(^{\text{∗}}) of (a). An integer (y) is the (k)-majority of array (b) if (y) appears at least (\lfloor \frac{|b|+1}{2} \rfloor +k) times in (b), where (|b|) represents the length of (b). Note that (b) may not necessarily have a (k)-majority. (^{\text{∗}})An array (b) is a subarray of an array (a) if (b) can be obtained from (a) by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. The first line contains an integer (t) ((1 \leq t \leq 10^4)) — the number of test cases. The first line of each test case contains two integers (n) and (q) ((1 \leq n, q \leq 3 \cdot 10^5)) — the length of (a) and the number of queries. The following line contains (n) space-separated integers (a_1, a_2, \ldots, a_n) ((1 \leq a_i \leq n)). The following (q) lines contain two integers (i) and (x), denoting the query that replaces (a_i) with (x) ((1 \leq i, x \leq n)). It is guaranteed that the sum of (n) and the sum of (q) over all test cases does not exceed (3 \cdot 10^5). For each test case, output the answer to all queries on a single new line, separated by a space. |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
323712639 |
og.kostya |
H |
June 10, 2025, 5:04 a.m. |
OK |
C# 10 |
TESTS |
15 |
2030 |
118988800 |
|
|
|
323713346 |
og.kostya |
H |
June 10, 2025, 5:11 a.m. |
OK |
C# 13 |
TESTS |
15 |
2030 |
117760000 |
|
|
|
323712744 |
og.kostya |
H |
June 10, 2025, 5:05 a.m. |
OK |
C# 13 |
TESTS |
15 |
2327 |
126771200 |
|
|
|
323694467 |
jcelin |
H |
June 9, 2025, 10:59 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1093 |
69734400 |
|
|
|
323676105 |
pratyay_01 |
H |
June 9, 2025, 6:08 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1280 |
71987200 |
|
|
|
323698101 |
SpinSpen |
H |
June 10, 2025, 1:03 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1312 |
108544000 |
|
|
|
323656552 |
InvMod |
H |
June 9, 2025, 3:30 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1327 |
59392000 |
|
|
|
323715026 |
bubbarob19 |
H |
June 10, 2025, 5:30 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1342 |
64716800 |
|
|
|
323701663 |
HowToLearnML |
H |
June 10, 2025, 2:17 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1421 |
60416000 |
|
|
|
323676670 |
abotaha23 |
H |
June 9, 2025, 6:14 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1421 |
71065600 |
|
|
|
323633031 |
Mobobaki |
H |
June 9, 2025, 12:35 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1437 |
71680000 |
|
|
|
323644915 |
sunchaoyi |
H |
June 9, 2025, 2:02 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1499 |
74444800 |
|
|
|
323711687 |
Spad2e |
H |
June 10, 2025, 4:53 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
15 |
1515 |
75673600 |
|
|
|
323605458 |
tnhwe |
H |
June 9, 2025, 9:12 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1078 |
59596800 |
|
|
|
323654775 |
Julyyyyyyy |
H |
June 9, 2025, 3:16 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1202 |
77516800 |
|
|
|
323629672 |
vietbachleonkroos2326 |
H |
June 9, 2025, 12:11 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1249 |
60518400 |
|
|
|
323643486 |
wanggl |
H |
June 9, 2025, 1:51 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1249 |
90521600 |
|
|
|
323698532 |
VinnySJ |
H |
June 10, 2025, 1:14 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1250 |
74035200 |
|
|
|
323666668 |
surajchip2 |
H |
June 9, 2025, 4:50 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1264 |
75264000 |
|
|
|
323713066 |
fazliddin2001 |
H |
June 10, 2025, 5:08 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1265 |
90521600 |
|
|
|
323688048 |
FzArK |
H |
June 9, 2025, 8:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1296 |
88268800 |
|
|
|
323653663 |
anranxiaohunzhang |
H |
June 9, 2025, 3:07 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1358 |
84992000 |
|
|
|
323632149 |
OsamaAlmasri |
H |
June 9, 2025, 12:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
15 |
1374 |
96665600 |
|
|
|
323696025 |
424479543 |
H |
June 9, 2025, 11:54 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
421 |
37683200 |
|
|
|
323696110 |
424479543 |
H |
June 9, 2025, 11:58 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
452 |
38809600 |
|
|
|
323696215 |
424479543 |
H |
June 10, 2025, 12:02 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
467 |
37580800 |
|
|
|
323696091 |
424479543 |
H |
June 9, 2025, 11:57 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
515 |
37683200 |
|
|
|
323696004 |
424479543 |
H |
June 9, 2025, 11:53 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
578 |
37580800 |
|
|
|
323656665 |
MUZAN |
H |
June 9, 2025, 3:31 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
718 |
55603200 |
|
|
|
323612474 |
424479543 |
H |
June 9, 2025, 10:01 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
765 |
33894400 |
|
|
|
323612151 |
424479543 |
H |
June 9, 2025, 9:59 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
811 |
33792000 |
|
|
|
323637468 |
sahil_beck |
H |
June 9, 2025, 1:06 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
890 |
78745600 |
|
|
|
323635597 |
sahil_beck |
H |
June 9, 2025, 12:54 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
15 |
937 |
79974400 |
|
|
|
323671172 |
lyongwolf |
H |
June 9, 2025, 5:27 p.m. |
OK |
Java 21 |
TESTS |
15 |
1484 |
38400000 |
|
|
|
323670888 |
lyongwolf |
H |
June 9, 2025, 5:24 p.m. |
OK |
Java 21 |
TESTS |
15 |
1624 |
39219200 |
|
|
|
323697612 |
smilences |
H |
June 10, 2025, 12:50 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
2702 |
167936000 |
|
|
|
323606770 |
smilences |
H |
June 9, 2025, 9:20 a.m. |
OK |
PyPy 3-64 |
TESTS |
15 |
2983 |
161484800 |
|
|
remove filters
Back to search problems