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.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 2066 | Codeforces Round 1004 (Div. 1) | FINISHED | False | 7200 | 37121123 | Feb. 11, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 5423 ) | B | White Magic | PROGRAMMING | constructive algorithms greedy implementation |
We call a sequence (a_1, a_2, \ldots, a_n) magical if for all (1 \leq i \leq n-1) it holds that: (\operatorname{min}(a_1, \ldots, a_i) \geq \operatorname{mex}(a_{i+1}, \ldots, a_n)). In particular, any sequence of length (1) is considered magical . The minimum excluded (MEX) of a collection of integers (a_1, a_2, \ldots, a_k) is defined as the smallest non-negative integer (t) which does not occur in the collection (a). You are given a sequence (a) of (n) non-negative integers. Find the maximum possible length of a magical subsequence(^{\text{∗}}) of the sequence (a). (^{\text{∗}})A sequence (a) is a subsequence of a sequence (b) if (a) can be obtained from (b) by the deletion of several (possibly, zero or all) element from arbitrary positions. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains an integer (n) ((1 \leq n \leq 2 \cdot 10^5)) — the length of the sequence (a). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \leq a_i \leq 10^9)) — the elements of the sequence (a). It is guaranteed that the sum of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output a single number — the maximum possible length of a magical subsequence of the sequence (a). In the first test case, the sequence (4, 3, 2, 1, 0) is magical , since: (\operatorname{min}(4) = 4, \operatorname{mex}(3, 2, 1, 0) = 4). (4 \geq 4) (\operatorname{min}(4, 3) = 3, \operatorname{mex}(2, 1, 0) = 3). (3 \geq 3) (\operatorname{min}(4, 3, 2) = 2, \operatorname{mex}(1, 0) = 2). (2 \geq 2) (\operatorname{min}(4, 3, 2, 1) = 1, \operatorname{mex}(0) = 1). (1 \geq 1) In the second test case, the sequence (4, 3, 3, 2, 1, 0) is not magical |
| 139415 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 305705632 | og.kostya | B | Feb. 11, 2025, 5:32 p.m. | OK | C# 10 | TESTS | 16 | 108 | 3072000 | ||
| 305669777 | mban259 | B | Feb. 11, 2025, 3:45 p.m. | OK | C# 10 | TESTS | 16 | 249 | 40857600 | ||
| 305649460 | KellyWLJ | B | Feb. 11, 2025, 3:14 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 62 | 12288000 | ||
| 305692233 | Namine | B | Feb. 11, 2025, 4:25 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 78 | 0 | ||
| 305751881 | kanglr1013 | B | Feb. 12, 2025, 3:40 a.m. | OK | C++17 (GCC 7-32) | TESTS | 17 | 78 | 1843200 | ||
| 305650646 | _chroneZ | B | Feb. 11, 2025, 3:16 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 78 | 2457600 | ||
| 305648698 | MetalPower | B | Feb. 11, 2025, 3:13 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 78 | 8089600 | ||
| 305729206 | -adhd- | B | Feb. 11, 2025, 8:54 p.m. | OK | C++17 (GCC 7-32) | TESTS | 17 | 92 | 0 | ||
| 305712158 | Yugi.Hacker | B | Feb. 11, 2025, 6:10 p.m. | OK | C++17 (GCC 7-32) | TESTS | 17 | 93 | 0 | ||
| 305668576 | magnified | B | Feb. 11, 2025, 3:43 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 93 | 0 | ||
| 305664771 | lacito | B | Feb. 11, 2025, 3:37 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 93 | 0 | ||
| 305661968 | lwm7708 | B | Feb. 11, 2025, 3:32 p.m. | OK | C++17 (GCC 7-32) | TESTS | 16 | 93 | 102400 | ||
| 305747600 | www_bilibili_com | B | Feb. 12, 2025, 2:33 a.m. | OK | C++20 (GCC 13-64) | TESTS | 17 | 62 | 1740800 | ||
| 305744346 | rollerZ | B | Feb. 12, 2025, 1:34 a.m. | OK | C++20 (GCC 13-64) | TESTS | 17 | 62 | 2457600 | ||
| 305660370 | miscalculation53 | B | Feb. 11, 2025, 3:30 p.m. | OK | C++20 (GCC 13-64) | TESTS | 16 | 62 | 2969600 | ||
| 305752772 | Evan__Leo | B | Feb. 12, 2025, 3:52 a.m. | OK | C++20 (GCC 13-64) | TESTS | 17 | 62 | 3276800 | ||
| 305649169 | FrostLeaf | B | Feb. 11, 2025, 3:14 p.m. | OK | C++20 (GCC 13-64) | TESTS | 16 | 77 | 0 | ||
| 305644061 | ikaurov | B | Feb. 11, 2025, 3:08 p.m. | OK | C++20 (GCC 13-64) | TESTS | 16 | 77 | 0 | ||
| 305742051 | enslaved | B | Feb. 12, 2025, 12:47 a.m. | OK | C++20 (GCC 13-64) | TESTS | 17 | 77 | 102400 | ||
| 305636357 | Honey_Badger | B | Feb. 11, 2025, 3 p.m. | OK | C++20 (GCC 13-64) | TESTS | 16 | 77 | 819200 | ||
| 305654290 | Cubyte | B | Feb. 11, 2025, 3:21 p.m. | OK | C++20 (GCC 13-64) | TESTS | 16 | 77 | 1638400 | ||
| 305744018 | cqrcqr | B | Feb. 12, 2025, 1:28 a.m. | OK | C++20 (GCC 13-64) | TESTS | 17 | 77 | 2457600 | ||
| 305756220 | wakaka | B | Feb. 12, 2025, 4:35 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 17 | 77 | 0 | ||
| 305753905 | Enigmatic | B | Feb. 12, 2025, 4:06 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 17 | 77 | 102400 | ||
| 305639256 | MridulAhi | B | Feb. 11, 2025, 3:03 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 16 | 77 | 102400 | ||
| 305754729 | FangYifan | B | Feb. 12, 2025, 4:16 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 17 | 77 | 1945600 | ||
| 305716563 | Shik | B | Feb. 11, 2025, 6:40 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 17 | 77 | 1945600 | ||
| 305706270 | Naruto_x | B | Feb. 11, 2025, 5:35 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 16 | 77 | 2457600 | ||
| 305738384 | Chrisedyong | B | Feb. 11, 2025, 11:09 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 17 | 78 | 0 | ||
| 305733150 | Sahu_1402 | B | Feb. 11, 2025, 9:58 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 17 | 78 | 0 | ||
| 305705273 | Yufe1210 | B | Feb. 11, 2025, 5:30 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 16 | 78 | 102400 | ||
| 305665053 | Abd | B | Feb. 11, 2025, 3:37 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 16 | 78 | 102400 | ||
| 305703939 | hos.lyric | B | Feb. 11, 2025, 5:24 p.m. | OK | D | TESTS | 16 | 109 | 10240000 | ||
| 305651660 | Gassa | B | Feb. 11, 2025, 3:17 p.m. | OK | D | TESTS | 16 | 171 | 21504000 | ||
| 305742367 | rainboy | B | Feb. 12, 2025, 12:54 a.m. | OK | GNU C11 | TESTS | 17 | 93 | 1126400 | ||
| 305662938 | Quasicoherent | B | Feb. 11, 2025, 3:34 p.m. | OK | Java 21 | TESTS | 16 | 452 | 19046400 | ||
| 305667393 | Electromaster | B | Feb. 11, 2025, 3:41 p.m. | OK | Kotlin 1.9 | TESTS | 16 | 531 | 13107200 | ||
| 305672751 | Mukundan314 | B | Feb. 11, 2025, 3:50 p.m. | OK | PyPy 3-64 | TESTS | 16 | 171 | 21913600 | ||
| 305731593 | AA7med_N3GEH | B | Feb. 11, 2025, 9:29 p.m. | OK | PyPy 3-64 | TESTS | 17 | 171 | 29388800 | ||
| 305696202 | ow3nL | B | Feb. 11, 2025, 4:30 p.m. | OK | PyPy 3-64 | TESTS | 16 | 186 | 30515200 | ||
| 305681703 | hxu10 | B | Feb. 11, 2025, 4:06 p.m. | OK | PyPy 3-64 | TESTS | 16 | 187 | 31232000 | ||
| 305645511 | eepsilon | B | Feb. 11, 2025, 3:09 p.m. | OK | PyPy 3-64 | TESTS | 16 | 187 | 35328000 | ||
| 305668100 | LMeyling | B | Feb. 11, 2025, 3:42 p.m. | OK | PyPy 3-64 | TESTS | 16 | 202 | 25804800 | ||
| 305742364 | conqueror_of_tourist | B | Feb. 12, 2025, 12:54 a.m. | OK | PyPy 3-64 | TESTS | 17 | 202 | 27136000 | ||
| 305653442 | titia | B | Feb. 11, 2025, 3:19 p.m. | OK | PyPy 3-64 | TESTS | 16 | 202 | 27136000 | ||
| 305641661 | dyppp | B | Feb. 11, 2025, 3:05 p.m. | OK | PyPy 3-64 | TESTS | 16 | 202 | 27238400 | ||
| 305655988 | toam | B | Feb. 11, 2025, 3:23 p.m. | OK | PyPy 3-64 | TESTS | 16 | 218 | 26624000 | ||
| 305668471 | Jimanbanashi | B | Feb. 11, 2025, 3:42 p.m. | OK | Python 2 | TESTS | 16 | 249 | 9932800 | ||
| 305653149 | cologne1723 | B | Feb. 11, 2025, 3:19 p.m. | OK | Rust 2021 | TESTS | 16 | 92 | 3584000 | ||
| 305633789 | Egor | B | Feb. 11, 2025, 2:57 p.m. | OK | Rust 2021 | TESTS | 16 | 108 | 2662400 | ||
| 305644187 | sansen | B | Feb. 11, 2025, 3:08 p.m. | OK | Rust 2021 | TESTS | 16 | 108 | 5324800 |
Back to search problems