Kotlin Heroes: Episode 12

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
2087 Kotlin Heroes: Episode 12 FINISHED False 9000 32369123 April 7, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 163 ) E Color the Arrows PROGRAMMING *special *special dp dp

There are (n) arrows drawn in a row on a strip of paper, numbered from (1) to (n). Each arrow points either to the left or to the right. Initially, all arrows are painted blue. In one operation, you can repaint a blue arrow into red . For the first operation, you can choose any arrow. For each subsequent operation, you are only allowed to choose such an arrow that the arrow repainted on the previous operation points in its direction. That is, if the arrow repainted in the previous operation is a left arrow, then, for the current operation, you have to choose an arrow at a smaller index than the previous one. Similarly, if the previous arrow was a right arrow, the current one has to be at a greater index than it. Note that the arrows don't have to be adjacent. Each arrow has an integer reward for repainting it into red (which can be negative, positive, or zero). The final score is the sum of the rewards for the repainted arrows. What is the maximum score that can be achieved if you are allowed to perform any number of operations (including zero)? The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. In the first line of each test case, there is a single integer (n) ((1 \le n \le 3 \cdot 10^5)) — the number of arrows. In the second line, there is a string consisting of (n) characters ' < ' and/or ' > ' (ASCII codes 60 and 62, respectively). In the third line, there are (n) integers (c_1, c_2, \dots, c_n) ((-10^9 \le c_i \le 10^9)) — the reward for repainting each arrow. An additional constraint on the input: the sum of (n) over all test cases does not exceed (3 \cdot 10^5). For each test case, print a single integer — the maximum score that can be achieved if you are allowed to perform any number of operations (including zero). In the first test case, you can first repaint the arrow at index (2). This arrow points to the right, so in the next operation, you have t

Tutorials

141608

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
314387715 potatoo E April 7, 2025, 3:39 p.m. OK Kotlin 1.7 TESTS 20 406 36864000
314383056 Ra16bit E April 7, 2025, 3:12 p.m. OK Kotlin 1.7 TESTS 20 562 97587200
314389860 gsaunders E April 7, 2025, 3:52 p.m. OK Kotlin 1.7 TESTS 20 608 102707200
314389714 nguyenhoangminh2003 E April 7, 2025, 3:51 p.m. OK Kotlin 1.7 TESTS 20 671 55500800
314382532 WiwiHo E April 7, 2025, 3:10 p.m. OK Kotlin 1.7 TESTS 20 671 126464000
314398276 UniversalAdmin E April 7, 2025, 4:48 p.m. OK Kotlin 1.7 TESTS 20 734 156467200
314384609 tokitsukaze E April 7, 2025, 3:21 p.m. OK Kotlin 1.7 TESTS 20 780 117248000
314404388 DeanMenezes93 E April 7, 2025, 5:30 p.m. OK Kotlin 1.7 TESTS 20 796 101376000
314385452 baluteshih E April 7, 2025, 3:26 p.m. OK Kotlin 1.7 TESTS 20 811 143564800
314387759 Yae-Miko E April 7, 2025, 3:39 p.m. OK Kotlin 1.7 TESTS 20 827 112742400
314384414 __jk__ E April 7, 2025, 3:20 p.m. OK Kotlin 1.9 TESTS 20 186 0
314380431 arvindf232 E April 7, 2025, 2:59 p.m. OK Kotlin 1.9 TESTS 20 187 0
314390538 thenymphsofdelphi E April 7, 2025, 3:56 p.m. OK Kotlin 1.9 TESTS 20 218 0
314385603 joylintp E April 7, 2025, 3:27 p.m. OK Kotlin 1.9 TESTS 20 327 25804800
314383975 nuip E April 7, 2025, 3:17 p.m. OK Kotlin 1.9 TESTS 20 358 27136000
314406140 jagbarrameda E April 7, 2025, 5:44 p.m. OK Kotlin 1.9 TESTS 20 375 30412800
314395530 alexey.enkov E April 7, 2025, 4:30 p.m. OK Kotlin 1.9 TESTS 20 389 29798400
314393523 nik_exists E April 7, 2025, 4:16 p.m. OK Kotlin 1.9 TESTS 20 390 24268800
314388019 Algebrant E April 7, 2025, 3:41 p.m. OK Kotlin 1.9 TESTS 20 390 24678400
314379660 tabr E April 7, 2025, 2:55 p.m. OK Kotlin 1.9 TESTS 20 390 29696000

remove filters

Back to search problems