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 |
|---|---|---|---|---|---|---|
| 2077 | Codeforces Round 1008 (Div. 1) | FINISHED | False | 9000 | 34787723 | March 10, 2025, 2:45 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 338 ) | D | Maximum Polygon | PROGRAMMING | brute force data structures implementation math |
Given an array (a) of length (n), determine the lexicographically largest(^{\text{∗}}) subsequence(^{\text{†}}) (s) of (a) such that (s) can be the side lengths of a polygon. Recall that (s) can be the side lengths of a polygon if and only if (|s| \geq 3) and () 2 \cdot \max(s_1, s_2, \ldots, s_{|s|}) < s_1 + s_2 + \ldots + s_{|s|}. () If no such subsequence (s) exists, print (-1). (^{\text{∗}})A sequence (x) is lexicographically smaller than a sequence (y) if and only if one of the following holds: (x) is a prefix of (y), but (x \ne y); in the first position where (x) and (y) differ, the sequence (x) has a smaller element than the corresponding element in (y). (^{\text{†}})A sequence (x) is a subsequence of a sequence (y) if (x) can be obtained from (y) by deleting several (possibly zero or all) elements. 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 a single integer (n) ((3 \leq n \leq 2 \cdot 10^5)) — the length of the array (a). The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \leq a_i \leq 10^9)) — the array (a). It is guaranteed that the total sum of all values of (n) across all test cases does not exceed (2 \cdot 10^5). For each test case, output the answer in the following format: If the answer exists, output the following. In the first line, output the integer (k) ((1 \leq k \leq n)) — the length of the subsequence (s). In the second line, output (k) integers (s_1, s_2, \ldots, s_k) ((1 \leq s_i \leq 10^9), (s) is a subsequence of (a)) — the subsequence (s). Note that the desired output is the value, not the index. Otherwise, output a single line with the integer (-1). In the first test |
| Codeforces Round 1008 (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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 309893883 | tfgs | D | March 10, 2025, 11:18 p.m. | OK | C++17 (GCC 7-32) | TESTS | 81 | 156 | 4198400 | ||
| 309835355 | jiangbowen | D | March 10, 2025, 4:12 p.m. | OK | C++17 (GCC 7-32) | TESTS | 81 | 828 | 13721600 | ||
| 309851814 | grass8sheep | D | March 10, 2025, 4:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 81 | 1046 | 76083200 | ||
| 309852236 | ntherner | D | March 10, 2025, 4:54 p.m. | OK | C++17 (GCC 7-32) | TESTS | 81 | 1781 | 36352000 | ||
| 309907288 | Nlll | D | March 11, 2025, 3:17 a.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 108 | 4710400 | ||
| 309838725 | stepanov.aa | D | March 10, 2025, 4:19 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 124 | 5939200 | ||
| 309857175 | makrav | D | March 10, 2025, 5:08 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 139 | 10752000 | ||
| 309845258 | Brovko | D | March 10, 2025, 4:36 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 140 | 5939200 | ||
| 309885728 | jtnydv25 | D | March 10, 2025, 9:17 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 156 | 9728000 | ||
| 309843697 | BurnedChicken | D | March 10, 2025, 4:32 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 171 | 13619200 | ||
| 309883880 | jtnydv25 | D | March 10, 2025, 8:57 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 171 | 20889600 | ||
| 309841330 | Ormlis | D | March 10, 2025, 4:26 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 187 | 25907200 | ||
| 309851431 | kotatsugame | D | March 10, 2025, 4:52 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 202 | 15462400 | ||
| 309893730 | Clan328 | D | March 10, 2025, 11:15 p.m. | OK | C++20 (GCC 13-64) | TESTS | 81 | 218 | 36044800 | ||
| 309909376 | Merripium | D | March 11, 2025, 3:48 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 93 | 11776000 | ||
| 309880919 | Keshi | D | March 10, 2025, 8:25 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 109 | 16896000 | ||
| 309810661 | jiangly | D | March 10, 2025, 3:28 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 124 | 11776000 | ||
| 309880709 | Keshi | D | March 10, 2025, 8:23 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 124 | 16896000 | ||
| 309906791 | yyyz04 | D | March 11, 2025, 3:10 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 140 | 39833600 | ||
| 309831379 | Kevin114514 | D | March 10, 2025, 4:04 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 156 | 14950400 | ||
| 309905325 | STB6 | D | March 11, 2025, 2:50 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 171 | 37785600 | ||
| 309845693 | Petr | D | March 10, 2025, 4:37 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 187 | 25395200 | ||
| 309879316 | Mangooste | D | March 10, 2025, 8:09 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 203 | 25395200 | ||
| 309913169 | OIer_kzc | D | March 11, 2025, 4:41 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 81 | 249 | 13414400 | ||
| 309872070 | rainboy | D | March 10, 2025, 7 p.m. | OK | GNU C11 | TESTS | 81 | 952 | 6553600 | ||
| 309864764 | arnabmanna | D | March 10, 2025, 6:02 p.m. | OK | Java 21 | TESTS | 81 | 2937 | 27238400 | ||
| 309867257 | conqueror_of_tourist | D | March 10, 2025, 6:19 p.m. | OK | PyPy 3-64 | TESTS | 81 | 624 | 43520000 | ||
| 309859741 | chinerist | D | March 10, 2025, 5:13 p.m. | OK | PyPy 3-64 | TESTS | 81 | 2952 | 46284800 |
Back to search problems