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 |
|---|---|---|---|---|---|---|
| 2135 | Codeforces Round 1046 (Div. 1) | FINISHED | False | 10800 | 20013923 | Aug. 28, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 18217 ) | A | Against the Difference | PROGRAMMING | data structures dp |
We define that a block is an array where all elements in it are equal to the length of the array. For example, (3, 3, 3), (1), and (4, 4, 4, 4) are blocks , while (1, 1, 1) and (2, 3, 3) are not. An array is called neat if it can be obtained by the concatenation of an arbitrary number of blocks (possibly zero). Note that an empty array is always neat . You are given an array (a) consisting of (n) integers. Find the length of its longest neat subsequence(^{\text{∗}}). (^{\text{∗}})A sequence (c) is a subsequence of a sequence (a) if (c) can be obtained from (a) 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 \le n \le 2\cdot 10^5)) — the length of (a). The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((1 \le a_i \le n)) — the elements of (a). It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, output a single integer — the length of the longest neat subsequence of (a). In the first test case, the whole array (1) is neat because it is a block . In the second test case, the whole array (2, 2) is neat because it is a block . In the third test case, the whole array (2,2,1,1) is neat because it is the concatenation of three blocks : (2,2), (1), and (1). In the fourth test case, one of the longest neat subsequences of (a) is (1, 3, 3, 3, 1). In the fifth test case, the longest neat subsequence of (a) is the empty subsequence. |
| Codeforces Round 1046 (Div. 1, Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 335950841 | og.kostya | A | Aug. 28, 2025, 2:43 p.m. | OK | C# 10 | TESTS | 21 | 156 | 8806400 | ||
| 335950416 | -firefly- | A | Aug. 28, 2025, 2:43 p.m. | OK | C# 13 | TESTS | 21 | 203 | 18944000 | ||
| 336082198 | YuJun1024 | A | Aug. 29, 2025, 4:42 a.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 92 | 4096000 | ||
| 336083259 | lakkshyag | A | Aug. 29, 2025, 4:56 a.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 3174400 | ||
| 336071818 | kangleni | A | Aug. 29, 2025, 2:02 a.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 4096000 | ||
| 336069996 | XING3523 | A | Aug. 29, 2025, 1:29 a.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 4096000 | ||
| 335950792 | Lawali | A | Aug. 28, 2025, 2:43 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 4096000 | ||
| 335946714 | Ylx22 | A | Aug. 28, 2025, 2:39 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 4096000 | ||
| 335994924 | yzr233 | A | Aug. 28, 2025, 3:36 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 9625600 | ||
| 335954450 | lostkeytoreach | A | Aug. 28, 2025, 2:46 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 93 | 18329600 | ||
| 335960462 | samkim21 | A | Aug. 28, 2025, 2:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 108 | 2355200 | ||
| 335945500 | mickeyjung | A | Aug. 28, 2025, 2:37 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 108 | 2355200 | ||
| 335947459 | Sanae | A | Aug. 28, 2025, 2:40 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 7270400 | ||
| 335946130 | max0810 | A | Aug. 28, 2025, 2:38 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 8601600 | ||
| 335945802 | furry | A | Aug. 28, 2025, 2:38 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 77 | 10444800 | ||
| 336066782 | Austin__Griffin | A | Aug. 29, 2025, 12:06 a.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 78 | 6451200 | ||
| 336066438 | Gold14526 | A | Aug. 28, 2025, 11:53 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 78 | 6451200 | ||
| 335956906 | timreizin | A | Aug. 28, 2025, 2:49 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 93 | 0 | ||
| 335959213 | hei_yu_bai | A | Aug. 28, 2025, 2:51 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 93 | 1740800 | ||
| 335948746 | mewmewmew | A | Aug. 28, 2025, 2:41 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 93 | 4300800 | ||
| 335959442 | ItsTimeToCookSundarSTEM | A | Aug. 28, 2025, 2:51 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 93 | 4915200 | ||
| 335945911 | Xellos | A | Aug. 28, 2025, 2:38 p.m. | OK | C++20 (GCC 13-64) | TESTS | 21 | 93 | 4915200 | ||
| 336071182 | ArrogHie | A | Aug. 29, 2025, 1:54 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 1843200 | ||
| 335945572 | caterpillow | A | Aug. 28, 2025, 2:38 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 5017600 | ||
| 335952635 | xcx2010 | A | Aug. 28, 2025, 2:45 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 8806400 | ||
| 335958799 | yanjiadong0016 | A | Aug. 28, 2025, 2:51 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 20787200 | ||
| 335947863 | nullptr_qwq | A | Aug. 28, 2025, 2:40 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 77 | 25190400 | ||
| 336078569 | donghaocheng | A | Aug. 29, 2025, 3:47 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 92 | 5632000 | ||
| 335959753 | little_rain | A | Aug. 28, 2025, 2:51 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 93 | 4812800 | ||
| 336072588 | link1k | A | Aug. 29, 2025, 2:15 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 93 | 4915200 | ||
| 336066533 | 1egend | A | Aug. 28, 2025, 11:56 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 93 | 4915200 | ||
| 335967820 | Yuichiro17 | A | Aug. 28, 2025, 2:59 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 21 | 93 | 4915200 | ||
| 335945242 | hos.lyric | A | Aug. 28, 2025, 2:37 p.m. | OK | D | TESTS | 21 | 140 | 21094400 | ||
| 335957706 | pengin_2000 | A | Aug. 28, 2025, 2:49 p.m. | OK | GNU C11 | TESTS | 21 | 108 | 4096000 | ||
| 335963716 | Transformer911 | A | Aug. 28, 2025, 2:55 p.m. | OK | Go | TESTS | 21 | 140 | 22528000 | ||
| 336082755 | ccj123 | A | Aug. 29, 2025, 4:49 a.m. | OK | Java 21 | TESTS | 21 | 312 | 17305600 | ||
| 336052607 | sangeet_04 | A | Aug. 28, 2025, 7:37 p.m. | OK | Java 21 | TESTS | 21 | 374 | 14950400 | ||
| 335950235 | Quasicoherent | A | Aug. 28, 2025, 2:42 p.m. | OK | Java 21 | TESTS | 21 | 405 | 10342400 | ||
| 335968180 | yehara | A | Aug. 28, 2025, 3 p.m. | OK | Java 21 | TESTS | 21 | 624 | 7577600 | ||
| 336085441 | harihk24 | A | Aug. 29, 2025, 5:22 a.m. | OK | Java 21 | TESTS | 21 | 906 | 86835200 | ||
| 335959839 | Sincerely_yours | A | Aug. 28, 2025, 2:52 p.m. | OK | Kotlin 1.9 | TESTS | 21 | 467 | 52838400 | ||
| 335945385 | Tlatoani | A | Aug. 28, 2025, 2:37 p.m. | OK | Kotlin 2.2 | TESTS | 21 | 390 | 25702400 | ||
| 335947864 | fatalerror | A | Aug. 28, 2025, 2:40 p.m. | OK | PyPy 3-64 | TESTS | 21 | 171 | 35225600 | ||
| 335947733 | toam | A | Aug. 28, 2025, 2:40 p.m. | OK | PyPy 3-64 | TESTS | 21 | 186 | 37273600 | ||
| 335954969 | LMeyling | A | Aug. 28, 2025, 2:47 p.m. | OK | PyPy 3-64 | TESTS | 21 | 186 | 38604800 | ||
| 335952411 | ValeriyShiyan | A | Aug. 28, 2025, 2:45 p.m. | OK | PyPy 3-64 | TESTS | 21 | 187 | 33075200 | ||
| 335955167 | eepsilon | A | Aug. 28, 2025, 2:47 p.m. | OK | PyPy 3-64 | TESTS | 21 | 187 | 38400000 | ||
| 335946703 | bcollet | A | Aug. 28, 2025, 2:39 p.m. | OK | PyPy 3-64 | TESTS | 21 | 202 | 37990400 | ||
| 335949896 | 34z12000 | A | Aug. 28, 2025, 2:42 p.m. | OK | PyPy 3-64 | TESTS | 21 | 203 | 35225600 | ||
| 335966990 | bronze_coder | A | Aug. 28, 2025, 2:59 p.m. | OK | PyPy 3-64 | TESTS | 21 | 218 | 35840000 | ||
| 335949532 | tassei903 | A | Aug. 28, 2025, 2:42 p.m. | OK | PyPy 3-64 | TESTS | 21 | 218 | 36249600 | ||
| 335955259 | detteiuu | A | Aug. 28, 2025, 2:47 p.m. | OK | PyPy 3-64 | TESTS | 21 | 233 | 32665600 | ||
| 335951743 | Jimanbanashi | A | Aug. 28, 2025, 2:44 p.m. | OK | Python 2 | TESTS | 21 | 1061 | 10137600 | ||
| 336071472 | alumkal | A | Aug. 29, 2025, 1:58 a.m. | OK | Python 3 | TESTS | 21 | 515 | 48435200 | ||
| 336071570 | alumkal | A | Aug. 29, 2025, 1:59 a.m. | OK | Python 3 | TESTS | 21 | 671 | 68403200 | ||
| 335945824 | Sugar_fan | A | Aug. 28, 2025, 2:38 p.m. | OK | Rust 2021 | TESTS | 21 | 124 | 10752000 | ||
| 335948422 | darkkcyan | A | Aug. 28, 2025, 2:41 p.m. | OK | Rust 2024 | TESTS | 21 | 171 | 40345600 |
Back to search problems