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 |
|---|---|---|---|---|---|---|
| 2236 | Codeforces Round 1103 (Div. 3) | FINISHED | False | 9000 | 2301933 | June 12, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 5875 ) | E | Friendly Gifts | PROGRAMMING | dp |
Arseniy decided to make his friends Dabir and Egor happy. For this, he decided to give each of them an array of numbers of the same length . An array (b) is called good if its elements can be rearranged so that for all (i \gt 1) the condition (b_i - b_{i - 1} = 1) holds. Arseniy wants Dabir and Egor to be able to play with these arrays. For this, the following conditions must be satisfied: Each of the given arrays is good . If you write one array after the other (in other words, concatenate them), the resulting array is also good . Arseniy already has an array (a) of length (n). He plans to cut both arrays from (a), that is, to choose two non-overlapping subsegments of the same length . Help Arseniy determine the maximum possible length of the resulting arrays. The first line contains a single integer (t) ((1 \le t \le 1000)) — the number of test cases. Then (t) test cases follow. The first line of each test case contains a single integer (n) ((1 \le n \le 6000)). The second line contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le n)). It is guaranteed that the sum of (n) over all test cases does not exceed (6000). For each test case, output a single integer — the maximum possible length of the arrays. In the first sample, it is impossible to select (2) arrays, so the answer is (0). In the second sample, the maximum length of the selected arrays is (1). Arrays (1) and (2) can be selected. In the fourth sample, the maximum length of the selected arrays is (2). You can select arrays (2, 1) and (4, 3). In the fifth sample, the maximum length of the selected arrays is (1). One way to select arrays is (1) and (2). Other methods are arrays (2) and (3), (3) and (4), or (4) and (5). |
| 154496 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 378457010 | yuki_Ishijo | E | June 12, 2026, 10:43 p.m. | OK | C# 13 | TESTS | 27 | 281 | 148172800 | ||
| 378493236 | sayan_mandal | E | June 13, 2026, 9:29 a.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 93 | 614400 | ||
| 378562186 | 77angadkumar | E | June 14, 2026, 12:42 a.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 93 | 1126400 | ||
| 378524787 | WuSh | E | June 13, 2026, 2:38 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 93 | 1126400 | ||
| 378509543 | gideonbeerens | E | June 13, 2026, 12:02 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 109 | 0 | ||
| 378538299 | panduwapanda | E | June 13, 2026, 4:48 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 109 | 1126400 | ||
| 378558068 | CardsPack | E | June 13, 2026, 9:25 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 125 | 0 | ||
| 378576295 | chaoyi88906 | E | June 14, 2026, 6:11 a.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 125 | 1024000 | ||
| 378554324 | Hiten_cp | E | June 13, 2026, 7:58 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 125 | 1126400 | ||
| 378547843 | shreyanshpal777 | E | June 13, 2026, 6:24 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 125 | 1126400 | ||
| 378544458 | Itadoriyuzi | E | June 13, 2026, 5:51 p.m. | OK | C++17 (GCC 7-32) | TESTS | 27 | 125 | 1126400 | ||
| 378492243 | Vraj_1512 | E | June 13, 2026, 9:19 a.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 78 | 0 | ||
| 378513148 | Devesh77 | E | June 13, 2026, 12:36 p.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 93 | 1228800 | ||
| 378563300 | porzlck | E | June 14, 2026, 1:29 a.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 93 | 1331200 | ||
| 378562427 | jeroa | E | June 14, 2026, 12:53 a.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 93 | 1331200 | ||
| 378510423 | dhyeythummar9 | E | June 13, 2026, 12:10 p.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 93 | 1331200 | ||
| 378503412 | kafuyuno | E | June 13, 2026, 11:05 a.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 93 | 1331200 | ||
| 378457425 | Imlevelingup | E | June 12, 2026, 11:01 p.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 93 | 1331200 | ||
| 378519245 | Lynkcat | E | June 13, 2026, 1:41 p.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 109 | 409600 | ||
| 378544615 | Desparade0 | E | June 13, 2026, 5:53 p.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 109 | 1228800 | ||
| 378471924 | abhi____123 | E | June 13, 2026, 5:21 a.m. | OK | C++20 (GCC 13-64) | TESTS | 27 | 109 | 1331200 | ||
| 378502003 | GodExcious | E | June 13, 2026, 10:52 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 62 | 102400 | ||
| 378507481 | GodExcious | E | June 13, 2026, 11:42 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 78 | 102400 | ||
| 378502384 | GodExcious | E | June 13, 2026, 10:56 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 78 | 102400 | ||
| 378567841 | Shoef_7d_Ynikak | E | June 14, 2026, 3:37 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 78 | 8908800 | ||
| 378567833 | Shoef_7d_Ynikak | E | June 14, 2026, 3:37 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 78 | 8908800 | ||
| 378567745 | Domzi1 | E | June 14, 2026, 3:35 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 78 | 8908800 | ||
| 378469465 | Deyja | E | June 13, 2026, 4:43 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 93 | 716800 | ||
| 378506319 | yvzuojianlianzi | E | June 13, 2026, 11:32 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 93 | 819200 | ||
| 378499726 | KAZHYI | E | June 13, 2026, 10:29 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 93 | 1126400 | ||
| 378556032 | Piromanchiz | E | June 13, 2026, 8:32 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 27 | 93 | 1331200 | ||
| 378474227 | Ghost_tf141 | E | June 13, 2026, 5:48 a.m. | OK | GNU C11 | TESTS | 27 | 312 | 144793600 | ||
| 378561404 | dzhi | E | June 13, 2026, 11:57 p.m. | OK | Java 21 | TESTS | 27 | 437 | 44646400 | ||
| 378561376 | mastacoda | E | June 13, 2026, 11:55 p.m. | OK | Java 21 | TESTS | 27 | 453 | 40857600 | ||
| 378546294 | ParthAgrawal1967 | E | June 13, 2026, 6:09 p.m. | OK | Java 21 | TESTS | 27 | 453 | 41676800 | ||
| 378527559 | oishiki22 | E | June 13, 2026, 3:03 p.m. | OK | Java 21 | TESTS | 27 | 468 | 42291200 | ||
| 378543233 | nolimitmac | E | June 13, 2026, 5:38 p.m. | OK | Java 21 | TESTS | 27 | 484 | 41779200 | ||
| 378453037 | Aayush.07 | E | June 12, 2026, 8:40 p.m. | OK | Java 21 | TESTS | 27 | 484 | 42086400 | ||
| 378534759 | justsaurab | E | June 13, 2026, 4:13 p.m. | OK | Java 21 | TESTS | 27 | 500 | 40960000 | ||
| 378452165 | Aayush.07 | E | June 12, 2026, 8:21 p.m. | OK | Java 21 | TESTS | 27 | 500 | 41164800 | ||
| 378547261 | vineetiwari | E | June 13, 2026, 6:18 p.m. | OK | Java 21 | TESTS | 27 | 515 | 44544000 | ||
| 378547244 | tiwari_selling_kulfi | E | June 13, 2026, 6:18 p.m. | OK | Java 21 | TESTS | 27 | 515 | 44544000 | ||
| 378534092 | Faithnhope | E | June 13, 2026, 4:07 p.m. | OK | PyPy 3 | TESTS | 27 | 1000 | 230195200 | ||
| 378527245 | DSKroc | E | June 13, 2026, 3 p.m. | OK | PyPy 3 | TESTS | 27 | 1343 | 247193600 | ||
| 378574988 | pearl62 | E | June 14, 2026, 5:53 a.m. | OK | PyPy 3-64 | TESTS | 27 | 437 | 47923200 | ||
| 378534851 | Mula_Wang | E | June 13, 2026, 4:14 p.m. | OK | PyPy 3-64 | TESTS | 27 | 500 | 50278400 | ||
| 378488673 | PhoenixLegacy | E | June 13, 2026, 8:48 a.m. | OK | PyPy 3-64 | TESTS | 27 | 828 | 292556800 | ||
| 378566787 | DairXP | E | June 14, 2026, 3:12 a.m. | OK | PyPy 3-64 | TESTS | 27 | 890 | 11878400 | ||
| 378528403 | 7a7a68 | E | June 13, 2026, 3:11 p.m. | OK | PyPy 3-64 | TESTS | 27 | 890 | 292556800 | ||
| 378520662 | shreshthadlakha | E | June 13, 2026, 1:56 p.m. | OK | PyPy 3-64 | TESTS | 27 | 1031 | 10137600 | ||
| 378469216 | golomb | E | June 13, 2026, 4:39 a.m. | OK | PyPy 3-64 | TESTS | 27 | 1031 | 10854400 | ||
| 378557189 | eric899 | E | June 13, 2026, 8:59 p.m. | OK | PyPy 3-64 | TESTS | 27 | 1062 | 456806400 | ||
| 378567493 | VGCos | E | June 14, 2026, 3:29 a.m. | OK | PyPy 3-64 | TESTS | 27 | 1328 | 292249600 | ||
| 378449742 | sr_9896 | E | June 12, 2026, 7:36 p.m. | OK | PyPy 3-64 | TESTS | 27 | 1437 | 488652800 | ||
| 378494205 | bqn | E | June 13, 2026, 9:38 a.m. | OK | Rust 2021 | TESTS | 27 | 2921 | 0 | ||
| 378516769 | hakansabol | E | June 13, 2026, 1:15 p.m. | OK | Rust 2024 | TESTS | 27 | 203 | 32256000 | ||
| 378549653 | warks | E | June 13, 2026, 6:45 p.m. | OK | Rust 2024 | TESTS | 27 | 1812 | 215961600 | ||
| 378516602 | hakansabol | E | June 13, 2026, 1:13 p.m. | OK | Rust 2024 | TESTS | 27 | 2671 | 123494400 |
Back to search problems