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 |
---|---|---|---|---|---|---|
1997 | Educational Codeforces Round 168 (Rated for Div. 2) | FINISHED | False | 7200 | 9473099 | July 30, 2024, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 21964 ) | C | Even Positions | PROGRAMMING | greedy |
B"Monocarp had a regular bracket sequence s of length n ( n is even). He even came up with his own way to calculate its cost. He knows that in a regular bracket sequence (RBS), each opening bracket is paired up with the corresponding closing bracket. So he decided to calculate the cost of RBS as the sum of distances between pairs of corresponding bracket pairs. For example, let's look at RBS (())(). It has three pairs of brackets: Unfortunately, due to data corruption, Monocarp lost all characters on odd positions s_1, s_3, ... , s_{n-1} . Only characters on even positions ( s_2, s_4, ... , s_{n} ) remain. For example, (())() turned to _(_)_). Monocarp wants to restore his RBS by placing brackets on the odd positions. But since the restored RBS may not be unique, he wants to choose one with minimum cost. It's too hard to do for Monocarp alone, so can you help him? Reminder: A regular bracket sequence is a string consisting of only brackets, such that this sequence, when inserted 1-s and +-s, gives a valid mathematical expression. For example, (), (()) or (()())() are RBS, while ), ()( or ())(() are not. The first line contains a single integer t ( 1 <= t <= 5000 ) -- the number of test cases. Next t cases follow. The first line of each test case contains a single integer n ( 2 <= n <= 2 cdot 10^5 ; n is even) -- the length of string s . The second line of each test case contains a string s of length n , where all characters on the odd positions are '_' and all characters on the even positions are either '(' or ')'. Additional constraints: For each test case, print one integer -- the minimum cost of the regular bracket sequence that can be obtained from s by replacing '_'-s with brackets. In the first test case, it's optimal to make s equal to (())(). The cost of s will be equal to 3 + 1 + 1 = 5 . In the second test case, the only option is to make "... |
Video Tutorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
273645563 | Ray_Wu | C | July 31, 2024, 1:50 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 31 | 1024000 | ||
273669438 | GDivyanshu3012 | C | July 31, 2024, 5:59 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273662113 | scream_g0d | C | July 31, 2024, 4:44 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273658808 | Rahul-2819 | C | July 31, 2024, 4:06 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273654340 | UltraInstncT | C | July 31, 2024, 3:20 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273653472 | New_Bie_21 | C | July 31, 2024, 3:12 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273647888 | qifan_maker | C | July 31, 2024, 2:16 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273645699 | summery_ | C | July 31, 2024, 1:52 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273642017 | zxliu66 | C | July 31, 2024, 1:05 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273640383 | tzzl3035 | C | July 31, 2024, 12:36 a.m. | OK | C++14 (GCC 6-32) | TESTS | 7 | 46 | 0 | ||
273644974 | patilkalash33 | C | July 31, 2024, 1:43 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 31 | 0 | ||
273643457 | wudibaolong0904 | C | July 31, 2024, 1:24 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 31 | 102400 | ||
273669762 | rIchADwIvedI_2025 | C | July 31, 2024, 6:02 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273669755 | shubham109yadav | C | July 31, 2024, 6:02 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273669270 | Benzene-C6H6 | C | July 31, 2024, 5:58 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273668875 | Drink_Medicine | C | July 31, 2024, 5:55 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273668874 | Angelo2L8 | C | July 31, 2024, 5:54 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273668312 | gameface_123 | C | July 31, 2024, 5:49 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273667710 | priyanshubansal12 | C | July 31, 2024, 5:44 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273667317 | xing_yao | C | July 31, 2024, 5:40 a.m. | OK | C++17 (GCC 7-32) | TESTS | 7 | 46 | 0 | ||
273666207 | Himanshu_Singh_cpp | C | July 31, 2024, 5:29 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 0 | ||
273665586 | gyhwhitenight | C | July 31, 2024, 5:23 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 0 | ||
273648967 | Shady_Mo | C | July 31, 2024, 2:28 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 0 | ||
273641192 | Maikyou | C | July 31, 2024, 12:52 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 0 | ||
273627247 | ansh_1012 | C | July 30, 2024, 8:39 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 0 | ||
273605677 | priyanshu_pandey_core | C | July 30, 2024, 5:34 p.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 0 | ||
273660440 | yanghongyan | C | July 31, 2024, 4:25 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 31 | 1638400 | ||
273669788 | hzk_cpp | C | July 31, 2024, 6:02 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 46 | 0 | ||
273669167 | woshi-juruo | C | July 31, 2024, 5:57 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 46 | 0 | ||
273669032 | jacksonmears | C | July 31, 2024, 5:56 a.m. | OK | C++20 (GCC 13-64) | TESTS | 7 | 46 | 0 | ||
273624388 | X7124-4E6LE583K3R | C | July 30, 2024, 8:01 p.m. | OK | GNU C11 | TESTS | 7 | 46 | 307200 | ||
273641576 | aWay228 | C | July 31, 2024, 12:58 a.m. | OK | Go | TESTS | 7 | 61 | 2969600 | ||
273625861 | Sylvester_ | C | July 30, 2024, 8:20 p.m. | OK | Java 21 | TESTS | 7 | 234 | 512000 | ||
273620524 | Amir_Tarek | C | July 30, 2024, 7:20 p.m. | OK | Java 21 | TESTS | 7 | 234 | 512000 | ||
273631828 | Elzok4 | C | July 30, 2024, 9:52 p.m. | OK | Java 21 | TESTS | 7 | 249 | 0 | ||
273620608 | Kempachi | C | July 30, 2024, 7:20 p.m. | OK | Java 21 | TESTS | 7 | 249 | 307200 | ||
273607400 | jai_bansal_007 | C | July 30, 2024, 5:45 p.m. | OK | Java 21 | TESTS | 7 | 249 | 512000 | ||
273605244 | jai_bansal_007 | C | July 30, 2024, 5:32 p.m. | OK | Java 21 | TESTS | 7 | 249 | 614400 | ||
273620369 | Amir_Tarek | C | July 30, 2024, 7:18 p.m. | OK | Java 21 | TESTS | 7 | 249 | 716800 | ||
273648701 | -Jarvis- | C | July 31, 2024, 2:25 a.m. | OK | Java 21 | TESTS | 7 | 265 | 0 | ||
273640741 | -Jarvis- | C | July 31, 2024, 12:43 a.m. | OK | Java 21 | TESTS | 7 | 265 | 409600 | ||
273609433 | Aviralpatel_0526 | C | July 30, 2024, 5:56 p.m. | OK | Java 21 | TESTS | 7 | 265 | 716800 | ||
273615690 | etian6795 | C | July 30, 2024, 6:38 p.m. | OK | Java 8 | TESTS | 7 | 140 | 0 | ||
273603983 | faresbadr316 | C | July 30, 2024, 5:25 p.m. | OK | Java 8 | TESTS | 7 | 140 | 0 | ||
273607284 | Kanishka_bansode | C | July 30, 2024, 5:44 p.m. | OK | Java 8 | TESTS | 7 | 156 | 0 | ||
273615260 | Sumitsingh7 | C | July 30, 2024, 6:35 p.m. | OK | Java 8 | TESTS | 7 | 156 | 6656000 | ||
273639453 | Alignment | C | July 31, 2024, 12:14 a.m. | OK | Java 8 | TESTS | 7 | 171 | 0 | ||
273637356 | Yousef_Badr | C | July 30, 2024, 11:59 p.m. | OK | Java 8 | TESTS | 7 | 171 | 0 | ||
273639976 | ifelsegawd | C | July 31, 2024, 12:27 a.m. | OK | Java 8 | TESTS | 7 | 187 | 0 | ||
273636389 | nis1234 | C | July 30, 2024, 11:36 p.m. | OK | Java 8 | TESTS | 7 | 187 | 0 | ||
273621355 | Divyansh_mnnit | C | July 30, 2024, 7:28 p.m. | OK | Java 8 | TESTS | 7 | 187 | 0 | ||
273658210 | rujuldwivedi | C | July 31, 2024, 4 a.m. | OK | Java 8 | TESTS | 7 | 202 | 0 | ||
273601394 | conqueror_of_womais | C | July 30, 2024, 5:12 p.m. | OK | PyPy 3 | TESTS | 7 | 187 | 4300800 | ||
273644687 | Giantpanda | C | July 31, 2024, 1:40 a.m. | OK | PyPy 3 | TESTS | 7 | 265 | 7884800 | ||
273605224 | MTA9402 | C | July 30, 2024, 5:32 p.m. | OK | PyPy 3 | TESTS | 7 | 281 | 7680000 | ||
273644885 | Giantpanda | C | July 31, 2024, 1:42 a.m. | OK | PyPy 3 | TESTS | 7 | 281 | 13926400 | ||
273604231 | sree1801 | C | July 30, 2024, 5:26 p.m. | OK | PyPy 3 | TESTS | 7 | 296 | 12390400 | ||
273620389 | gardengnome | C | July 30, 2024, 7:18 p.m. | OK | PyPy 3-64 | TESTS | 7 | 93 | 3481600 | ||
273669007 | sreeja_7 | C | July 31, 2024, 5:56 a.m. | OK | PyPy 3-64 | TESTS | 7 | 108 | 2867200 | ||
273665345 | Umar_SundarSTEM | C | July 31, 2024, 5:20 a.m. | OK | PyPy 3-64 | TESTS | 7 | 108 | 2867200 | ||
273645232 | Shaheer_SundarSTEM | C | July 31, 2024, 1:46 a.m. | OK | PyPy 3-64 | TESTS | 7 | 108 | 13107200 | ||
273666359 | AyuAnchor | C | July 31, 2024, 5:31 a.m. | OK | PyPy 3-64 | TESTS | 7 | 109 | 2150400 | ||
273649762 | Ghazanfar.Abbas123 | C | July 31, 2024, 2:36 a.m. | OK | PyPy 3-64 | TESTS | 7 | 109 | 2867200 | ||
273669058 | swayam3108 | C | July 31, 2024, 5:56 a.m. | OK | PyPy 3-64 | TESTS | 7 | 109 | 3379200 | ||
273641091 | cy171 | C | July 31, 2024, 12:50 a.m. | OK | PyPy 3-64 | TESTS | 7 | 109 | 3379200 | ||
273660922 | lean_shorty | C | July 31, 2024, 4:31 a.m. | OK | PyPy 3-64 | TESTS | 7 | 109 | 3584000 | ||
273665374 | _VarshiniReddy_ | C | July 31, 2024, 5:20 a.m. | OK | PyPy 3-64 | TESTS | 7 | 109 | 3788800 | ||
273651043 | H_Inam | C | July 31, 2024, 2:49 a.m. | OK | Python 3 | TESTS | 7 | 77 | 0 | ||
273669591 | Aravindreddy45 | C | July 31, 2024, 6 a.m. | OK | Python 3 | TESTS | 7 | 93 | 0 | ||
273664099 | H_Inam | C | July 31, 2024, 5:07 a.m. | OK | Python 3 | TESTS | 7 | 93 | 0 | ||
273664394 | 2210030140 | C | July 31, 2024, 5:10 a.m. | OK | Python 3 | TESTS | 7 | 108 | 0 | ||
273605665 | MintMihir | C | July 30, 2024, 5:34 p.m. | OK | Python 3 | TESTS | 7 | 108 | 716800 | ||
273644227 | H098 | C | July 31, 2024, 1:35 a.m. | OK | Python 3 | TESTS | 7 | 108 | 1536000 | ||
273609562 | aryui_2902 | C | July 30, 2024, 5:57 p.m. | OK | Python 3 | TESTS | 7 | 109 | 819200 | ||
273643696 | Jaideep19 | C | July 31, 2024, 1:27 a.m. | OK | Python 3 | TESTS | 7 | 124 | 0 | ||
273625898 | kennethhhhh | C | July 30, 2024, 8:21 p.m. | OK | Python 3 | TESTS | 7 | 124 | 102400 | ||
273662126 | gagan_kushwah_25 | C | July 31, 2024, 4:44 a.m. | OK | Python 3 | TESTS | 7 | 124 | 204800 | ||
273663726 | codesbyayush | C | July 31, 2024, 5:02 a.m. | OK | Rust 2021 | TESTS | 7 | 46 | 0 |
Back to search problems