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 |
|---|---|---|---|---|---|---|
| 2268 | Codeforces Round 1124 (Div. 1) | FINISHED | False | 9000 | 746666 | Sept. 26, 2026, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 556 ) | D | AghaBalaSar and Hamed | PROGRAMMING | data structures dp trees |
You are given a permutation(^{\text{∗}}) (p) of length (n). For each index (i), you may move in one step to: any index (j \lt i), or the first index (j \gt i) such that (p_j \gt p_i) (if such an index exists), You can always move to any position on the left. On the right, you can move only to the nearest position whose value is strictly greater than the current one. Your task is to compute: ()\sum_{1 \le i,j \le n} f(i,j).() (^{\text{∗}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). 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) ((1 \leq n \leq 10^6)) — the length of (p). The second line of each test case contains (n) distinct integers (p_1,p_2,\ldots,p_n) ((1\le p_i\le n)) — the elements of (p). It is guaranteed that the sum of (n) over all test cases does not exceed (10^6). For each test case, print a single integer — the value of (\sum\limits_{1 \le i,j \le n} f(i,j)). In the first test case, (f(1, 2) + f(2, 1) = 1 + 1 = 2). In the second test case, (f(1, 2) + f(2, 1) = 0 + 1 = 1). In the third test case, (f(1, 2) + f(1, 3) + f(2, 1) + f(2, 3) + f(3, 1) + f(3, 2) = 1 + 0 + 1 + 0 + 1 + 1 = 4). In the fourth test case, (f(1, 2) + f(1, 3) + f(2, 1) + f(2, 3) + f(3, 1) + f(3, 2) = 1 + 2 + 1 + 1 + 1 + 1 = 7). |
| 157140 |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 392258490 | Midhilesh | D | Sept. 26, 2026, 10:38 p.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 234 | 24371200 | ||
| 392280219 | wwangcc | D | Sept. 27, 2026, 4:04 a.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 250 | 24064000 | ||
| 392277837 | IlllIlll | D | Sept. 27, 2026, 3:18 a.m. | OK | C++17 (GCC 7-32) | TESTS | 41 | 250 | 29184000 | ||
| 392214376 | quanjun | D | Sept. 26, 2026, 3:53 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 281 | 16076800 | ||
| 392217018 | DemberS06 | D | Sept. 26, 2026, 4:01 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 281 | 40345600 | ||
| 392222981 | intjr | D | Sept. 26, 2026, 4:21 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 281 | 48435200 | ||
| 392229352 | chhillarankit74 | D | Sept. 26, 2026, 4:45 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 296 | 44339200 | ||
| 392234399 | al3xstr33t | D | Sept. 26, 2026, 5:04 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 312 | 42086400 | ||
| 392214573 | cowgoodsheep | D | Sept. 26, 2026, 3:54 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 312 | 100761600 | ||
| 392233184 | xtzic | D | Sept. 26, 2026, 5 p.m. | OK | C++17 (GCC 7-32) | TESTS | 40 | 343 | 30720000 | ||
| 392216219 | jn_275 | D | Sept. 26, 2026, 3:58 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 187 | 17408000 | ||
| 392276204 | Juche510 | D | Sept. 27, 2026, 2:41 a.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 187 | 28262400 | ||
| 392233165 | zeroliebe | D | Sept. 26, 2026, 5 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 203 | 20070400 | ||
| 392242808 | surajchip2 | D | Sept. 26, 2026, 6:16 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 203 | 33894400 | ||
| 392222176 | strapple | D | Sept. 26, 2026, 4:18 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 203 | 185139200 | ||
| 392214348 | JDScript0117 | D | Sept. 26, 2026, 3:53 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 218 | 28057600 | ||
| 392220683 | opPO | D | Sept. 26, 2026, 4:13 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 218 | 45670400 | ||
| 392231820 | HeartBreakerKid | D | Sept. 26, 2026, 4:55 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 218 | 49868800 | ||
| 392227872 | Elysion | D | Sept. 26, 2026, 4:40 p.m. | OK | C++20 (GCC 13-64) | TESTS | 40 | 218 | 52531200 | ||
| 392255160 | mychecksdead | D | Sept. 26, 2026, 9:02 p.m. | OK | C++20 (GCC 13-64) | TESTS | 41 | 218 | 64409600 | ||
| 392278817 | gunuozhang | D | Sept. 27, 2026, 3:39 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 78 | 41267200 | ||
| 392228970 | gunuozhang | D | Sept. 26, 2026, 4:44 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 78 | 41267200 | ||
| 392208368 | hodza | D | Sept. 26, 2026, 3:37 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 109 | 43724800 | ||
| 392233443 | Milmon | D | Sept. 26, 2026, 5:01 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 187 | 36147200 | ||
| 392225390 | AksLolCoding | D | Sept. 26, 2026, 4:30 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 203 | 12800000 | ||
| 392264616 | ytfish | D | Sept. 27, 2026, 1:58 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 203 | 17305600 | ||
| 392264628 | B1eeding | D | Sept. 27, 2026, 1:59 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 203 | 32358400 | ||
| 392262398 | yh2022lizh | D | Sept. 27, 2026, 1:06 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 41 | 203 | 48128000 | ||
| 392227612 | bukhuk | D | Sept. 26, 2026, 4:38 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 203 | 96460800 | ||
| 392232073 | penguin133 | D | Sept. 26, 2026, 4:56 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 40 | 218 | 5632000 | ||
| 392229294 | Cybuster | D | Sept. 26, 2026, 4:45 p.m. | OK | D | TESTS | 40 | 296 | 69427200 | ||
| 392224775 | hardiknarang2509 | D | Sept. 26, 2026, 4:27 p.m. | OK | Java 21 | TESTS | 40 | 515 | 131993600 | ||
| 392251425 | MaxBuzz | D | Sept. 26, 2026, 8 p.m. | OK | Java 21 | TESTS | 41 | 1015 | 97484800 | ||
| 392232193 | Andr_k | D | Sept. 26, 2026, 4:57 p.m. | OK | PyPy 3-64 | TESTS | 40 | 406 | 129740800 | ||
| 392233569 | twosquares | D | Sept. 26, 2026, 5:02 p.m. | OK | PyPy 3-64 | TESTS | 40 | 671 | 139878400 | ||
| 392228450 | golomb | D | Sept. 26, 2026, 4:42 p.m. | OK | PyPy 3-64 | TESTS | 40 | 921 | 192921600 |
Back to search problems