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.
Problems
B'Vasya has a string s of length n consisting only of digits 0 and 1. Also he has an array a of length n . Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue together the remaining parts (any of them can be empty). For example, if he erases substring 111 from string 111110 he will get the string 110. Vasya gets a_x points for erasing substring of length x . Vasya wants to maximize his total points, so help him with this! The first line contains one integer n ( 1 <= n <= 100 ) -- the length of string s . The second line contains string s , consisting only of digits 0 and 1. The third line contains n integers a_1, a_2, ... a_n ( 1 <= a_i <= 10^9 ), where a_i is the number of points for erasing the substring of length i . Print one integer -- the maximum total points Vasya can get. In the first example the optimal sequence of erasings is: 1101001 rightarrow 111001 rightarrow 11101 rightarrow 1111 rightarrow varnothing . In the second example the optimal sequence of erasings is: 10101 rightarrow 1001 rightarrow 11 rightarrow varnothing . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
49054554 |
AFreeMan |
E |
Jan. 27, 2019, 12:43 p.m. |
OK |
Clang++17 Diagnostics |
TESTS |
37 |
155 |
64512000 |
|
2400 |
55227138 |
chaorenhaha |
E |
June 7, 2019, 2:42 a.m. |
OK |
FPC |
TESTS |
37 |
46 |
8601600 |
|
2400 |
49030200 |
rainboy |
E |
Jan. 26, 2019, 9:33 p.m. |
OK |
GNU C11 |
TESTS |
37 |
31 |
8089600 |
|
2400 |
49183119 |
luogu_bot1 |
E |
Jan. 30, 2019, 3:42 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
49097202 |
Jubair_2147483647 |
E |
Jan. 28, 2019, 10:13 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
49039491 |
shahidul_brur |
E |
Jan. 27, 2019, 5:50 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
51363042 |
weltyfjd1909 |
E |
March 16, 2019, 8:13 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
50643353 |
luogu_bot1 |
E |
March 1, 2019, 2:51 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
50338627 |
Hiasat |
E |
Feb. 22, 2019, 11:35 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
50268294 |
JasonWHY |
E |
Feb. 21, 2019, 5:49 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8499200 |
|
2400 |
49130477 |
xiaoshizhan |
E |
Jan. 29, 2019, 3:35 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
8806400 |
|
2400 |
49665271 |
YxwKeith |
E |
Feb. 9, 2019, 2:09 p.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
9113600 |
|
2400 |
69818544 |
liuweih |
E |
Jan. 30, 2020, 6:57 a.m. |
OK |
GNU C++11 |
TESTS |
37 |
31 |
9318400 |
|
2400 |
49521658 |
Roundgod |
E |
Feb. 6, 2019, 8:25 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
15 |
9318400 |
|
2400 |
49028285 |
ArshiaDadras |
E |
Jan. 26, 2019, 8:16 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
9318400 |
|
2400 |
49218152 |
IF_IR_A_1_IR |
E |
Jan. 30, 2019, 5:57 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
30 |
13414400 |
|
2400 |
49017067 |
Boson |
E |
Jan. 26, 2019, 5:10 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
49023646 |
rareone0602 |
E |
Jan. 26, 2019, 6:09 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
8294400 |
|
2400 |
49131031 |
anis028 |
E |
Jan. 29, 2019, 4:09 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
8499200 |
|
2400 |
61096235 |
compiler_101 |
E |
Sept. 23, 2019, 3:18 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
8499200 |
|
2400 |
50698676 |
sasuke_uchiha |
E |
March 2, 2019, 7:31 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
8499200 |
|
2400 |
49015768 |
monster |
E |
Jan. 26, 2019, 5:03 p.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
8499200 |
|
2400 |
54510451 |
pandawei |
E |
May 23, 2019, 6:48 a.m. |
OK |
GNU C++14 |
TESTS |
37 |
31 |
9318400 |
|
2400 |
49028644 |
ArshiaDadras |
E |
Jan. 26, 2019, 8:28 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
10956800 |
|
2400 |
49060906 |
KrK |
E |
Jan. 27, 2019, 3:24 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
30 |
12492800 |
|
2400 |
49064443 |
raja_123 |
E |
Jan. 27, 2019, 5 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
4300800 |
|
2400 |
53457919 |
betrue12 |
E |
April 28, 2019, 4:52 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
8192000 |
|
2400 |
49183127 |
vjudge1 |
E |
Jan. 30, 2019, 3:42 a.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
8499200 |
|
2400 |
49015029 |
chenrui9551 |
E |
Jan. 26, 2019, 4:58 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
9523200 |
|
2400 |
49121770 |
smartnj |
E |
Jan. 28, 2019, 7:43 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
9523200 |
|
2400 |
49026745 |
abhishek_20123 |
E |
Jan. 26, 2019, 7:24 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
9523200 |
|
2400 |
49018948 |
joseramont |
E |
Jan. 26, 2019, 5:21 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
9523200 |
|
2400 |
49018405 |
mohammadrobot |
E |
Jan. 26, 2019, 5:18 p.m. |
OK |
GNU C++17 |
TESTS |
37 |
31 |
9625600 |
|
2400 |
49549445 |
hqhs |
E |
Feb. 7, 2019, 4:12 a.m. |
OK |
Go |
TESTS |
37 |
1996 |
54374400 |
|
2400 |
49554210 |
hqhs |
E |
Feb. 7, 2019, 8:32 a.m. |
OK |
Go |
TESTS |
37 |
1996 |
58777600 |
|
2400 |
49033268 |
TheRaven |
E |
Jan. 27, 2019, 1:02 a.m. |
OK |
Java 8 |
TESTS |
37 |
124 |
4505600 |
|
2400 |
49030201 |
Dukkha |
E |
Jan. 26, 2019, 9:33 p.m. |
OK |
Java 8 |
TESTS |
37 |
124 |
5017600 |
|
2400 |
68934852 |
Hemose |
E |
Jan. 16, 2020, 12:28 p.m. |
OK |
Java 8 |
TESTS |
37 |
139 |
4403200 |
|
2400 |
49017352 |
flyman3046 |
E |
Jan. 26, 2019, 5:12 p.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
4403200 |
|
2400 |
49177387 |
YahiaBadr |
E |
Jan. 29, 2019, 9:45 p.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
4710400 |
|
2400 |
49061078 |
jenish9599 |
E |
Jan. 27, 2019, 3:28 p.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
4710400 |
|
2400 |
49027077 |
Ahmed_Diab |
E |
Jan. 26, 2019, 7:36 p.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
4710400 |
|
2400 |
49933163 |
nchn27 |
E |
Feb. 15, 2019, 5:55 a.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
4812800 |
|
2400 |
49076104 |
mattpk |
E |
Jan. 28, 2019, 3:12 a.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
6451200 |
|
2400 |
49271663 |
tsumit023 |
E |
Jan. 31, 2019, 2:11 p.m. |
OK |
Java 8 |
TESTS |
37 |
140 |
27136000 |
|
2400 |
49177753 |
Quaternion |
E |
Jan. 29, 2019, 10:04 p.m. |
OK |
Kotlin |
TESTS |
37 |
171 |
102400 |
|
2400 |
49050630 |
spookywooky |
E |
Jan. 27, 2019, 10:54 a.m. |
OK |
Kotlin |
TESTS |
37 |
265 |
78950400 |
|
2400 |
49349434 |
selpo |
E |
Feb. 2, 2019, 7:32 a.m. |
OK |
Mono C# |
TESTS |
37 |
343 |
20070400 |
|
2400 |
49183943 |
vjudge1 |
E |
Jan. 30, 2019, 4:27 a.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
9318400 |
|
2400 |
49183551 |
vjudge5 |
E |
Jan. 30, 2019, 4:05 a.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
9318400 |
|
2400 |
58576210 |
vjudge4 |
E |
Aug. 11, 2019, 12:30 p.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
9318400 |
|
2400 |
58544715 |
vjudge4 |
E |
Aug. 10, 2019, 3:59 p.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
10649600 |
|
2400 |
49036469 |
dyxx |
E |
Jan. 27, 2019, 3:41 a.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
10649600 |
|
2400 |
49179536 |
vjudge5 |
E |
Jan. 30, 2019, 12:09 a.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
10649600 |
|
2400 |
58496868 |
vjudge3 |
E |
Aug. 9, 2019, 12:33 p.m. |
OK |
MS C++ |
TESTS |
37 |
46 |
64102400 |
|
2400 |
51364936 |
vjudge2 |
E |
March 16, 2019, 9:07 a.m. |
OK |
MS C++ |
TESTS |
37 |
218 |
18636800 |
|
2400 |
51426332 |
petko_mitkov |
E |
March 17, 2019, 7:28 p.m. |
OK |
MS C++ 2017 |
TESTS |
37 |
46 |
8806400 |
|
2400 |
49227144 |
elvinaa |
E |
Jan. 31, 2019, 1:31 a.m. |
OK |
MS C++ 2017 |
TESTS |
37 |
156 |
21401600 |
|
2400 |
49036768 |
pajenegod |
E |
Jan. 27, 2019, 3:55 a.m. |
OK |
PyPy 2 |
TESTS |
37 |
327 |
8192000 |
|
2400 |
49036972 |
pajenegod |
E |
Jan. 27, 2019, 4:05 a.m. |
OK |
PyPy 2 |
TESTS |
37 |
343 |
8192000 |
|
2400 |
50889301 |
pajenegod |
E |
March 6, 2019, 12:35 p.m. |
OK |
PyPy 2 |
TESTS |
37 |
358 |
8089600 |
|
2400 |
49036526 |
pajenegod |
E |
Jan. 27, 2019, 3:44 a.m. |
OK |
PyPy 2 |
TESTS |
37 |
358 |
8089600 |
|
2400 |
49035802 |
pajenegod |
E |
Jan. 27, 2019, 3:09 a.m. |
OK |
PyPy 2 |
TESTS |
37 |
982 |
15769600 |
|
2400 |
49177356 |
Stephan |
E |
Jan. 29, 2019, 9:43 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
217 |
9011200 |
|
2400 |
49298215 |
Stephan |
E |
Feb. 1, 2019, 12:46 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
218 |
9011200 |
|
2400 |
49027370 |
111vad111 |
E |
Jan. 26, 2019, 7:45 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
374 |
8908800 |
|
2400 |
49051753 |
meooow |
E |
Jan. 27, 2019, 11:24 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
405 |
30924800 |
|
2400 |
49056683 |
meooow |
E |
Jan. 27, 2019, 1:35 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
436 |
30310400 |
|
2400 |
49064113 |
Bovniova |
E |
Jan. 27, 2019, 4:51 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
467 |
8396800 |
|
2400 |
49024271 |
Kiri8128 |
E |
Jan. 26, 2019, 6:20 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
499 |
12595200 |
|
2400 |
49069787 |
Bovniova |
E |
Jan. 27, 2019, 7:53 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
545 |
10035200 |
|
2400 |
57078191 |
saku7 |
E |
July 15, 2019, 6:13 a.m. |
OK |
PyPy 3 |
TESTS |
37 |
560 |
14438400 |
|
2400 |
49069923 |
Bovniova |
E |
Jan. 27, 2019, 7:59 p.m. |
OK |
PyPy 3 |
TESTS |
37 |
561 |
10035200 |
|
2400 |
49177454 |
Stephan |
E |
Jan. 29, 2019, 9:47 p.m. |
OK |
Python 3 |
TESTS |
37 |
1450 |
6041600 |
|
2400 |
49206288 |
alexander.kozlovsky.m |
E |
Jan. 30, 2019, 1:59 p.m. |
OK |
Python 3 |
TESTS |
37 |
1934 |
7372800 |
|
2400 |
49500403 |
kobae964 |
E |
Feb. 5, 2019, 2:53 p.m. |
OK |
Rust |
TESTS |
37 |
280 |
18022400 |
|
2400 |
49500325 |
kobae964 |
E |
Feb. 5, 2019, 2:51 p.m. |
OK |
Rust |
TESTS |
37 |
295 |
18022400 |
|
2400 |
remove filters
Back to search problems