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'You are given four integers n , c_0 , c_1 and h and a binary string s of length n . A binary string is a string consisting of characters 0 and 1 . You can change any character of the string s (the string should be still binary after the change). You should pay h coins for each change. After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 0 you should pay c_0 coins, to buy the character 1 you should pay c_1 coins. Find the minimum number of coins needed to buy the string. The first line contains a single integer t ( 1 <= q t <= q 10 ) -- the number of test cases. Next 2t lines contain descriptions of test cases. The first line of the description of each test case contains four integers n , c_{0} , c_{1} , h ( 1 <= q n, c_{0}, c_{1}, h <= q 1000 ). The second line of the description of each test case contains the binary string s of length n . For each test case print a single integer -- the minimum number of coins needed to buy the string. In the first test case, you can buy all characters and pay 3 coins, because both characters 0 and 1 costs 1 coin. In the second test case, you can firstly change 2 -nd and 4 -th symbols of the string from 1 to 0 and pay 2 coins for that. Your string will be 00000 . After that, you can buy the string and pay 5 cdot 10 = 50 coins for that. The total number of coins paid will be 2 + 50 = 52 . '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
98777460 |
sxvd |
A |
Nov. 18, 2020, 5:49 a.m. |
OK |
Clang++17 Diagnostics |
TESTS |
5 |
46 |
5222400 |
|
|
98768280 |
phgquynh2208 |
A |
Nov. 18, 2020, 2:31 a.m. |
OK |
FPC |
TESTS |
5 |
15 |
1228800 |
|
|
98737075 |
Aayush24 |
A |
Nov. 17, 2020, 4:34 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98749958 |
asif099 |
A |
Nov. 17, 2020, 5:49 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98750591 |
ja1467 |
A |
Nov. 17, 2020, 5:56 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98753721 |
MrS4g0 |
A |
Nov. 17, 2020, 6:37 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98755999 |
MrS4g0 |
A |
Nov. 17, 2020, 7:16 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98775958 |
namanbhatia11111 |
A |
Nov. 18, 2020, 5:24 a.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98751149 |
arpit.bharadwaj5 |
A |
Nov. 17, 2020, 6:02 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98731630 |
noob2181 |
A |
Nov. 17, 2020, 4:20 p.m. |
OK |
GNU C11 |
TESTS |
5 |
15 |
0 |
|
|
98732591 |
i_tm_hit_iron |
A |
Nov. 17, 2020, 4:23 p.m. |
OK |
GNU C11 |
TESTS |
5 |
30 |
0 |
|
|
98737624 |
windjade |
A |
Nov. 17, 2020, 4:36 p.m. |
OK |
GNU C11 |
TESTS |
5 |
30 |
0 |
|
|
98772803 |
201909250425 |
A |
Nov. 18, 2020, 4:19 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98777562 |
sinamhdv |
A |
Nov. 18, 2020, 5:51 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98777390 |
cloudyrain |
A |
Nov. 18, 2020, 5:48 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98777250 |
vjudge1 |
A |
Nov. 18, 2020, 5:46 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98777187 |
Hiio |
A |
Nov. 18, 2020, 5:45 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98776376 |
jabed_cste |
A |
Nov. 18, 2020, 5:31 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98775932 |
bobh |
A |
Nov. 18, 2020, 5:24 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98775068 |
MoIzzath |
A |
Nov. 18, 2020, 5:08 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98774198 |
Naruto_Uzumaki_ |
A |
Nov. 18, 2020, 4:49 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98773300 |
dblark |
A |
Nov. 18, 2020, 4:31 a.m. |
OK |
GNU C++11 |
TESTS |
5 |
15 |
0 |
|
|
98770397 |
abhinav2023 |
A |
Nov. 18, 2020, 3:25 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98771244 |
nishikanth |
A |
Nov. 18, 2020, 3:45 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98771277 |
omsingh5092 |
A |
Nov. 18, 2020, 3:45 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98771602 |
iqOage |
A |
Nov. 18, 2020, 3:53 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98771747 |
aditya_x |
A |
Nov. 18, 2020, 3:56 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98772647 |
733_3473 |
A |
Nov. 18, 2020, 4:16 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98773733 |
angelskid |
A |
Nov. 18, 2020, 4:39 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98777010 |
Mr_Himanshu |
A |
Nov. 18, 2020, 5:42 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98777454 |
19kanu30 |
A |
Nov. 18, 2020, 5:49 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98778033 |
Sanskar49 |
A |
Nov. 18, 2020, 5:58 a.m. |
OK |
GNU C++14 |
TESTS |
5 |
15 |
0 |
|
|
98751735 |
saurabh122 |
A |
Nov. 17, 2020, 6:09 p.m. |
OK |
GNU C++17 |
TESTS |
5 |
0 |
3993600 |
|
|
98775445 |
MDA_11 |
A |
Nov. 18, 2020, 5:15 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98778290 |
akshaymishra |
A |
Nov. 18, 2020, 6:02 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98777860 |
quickers |
A |
Nov. 18, 2020, 5:56 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98777677 |
fireLUFFY |
A |
Nov. 18, 2020, 5:53 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98777660 |
Code_Hunt |
A |
Nov. 18, 2020, 5:52 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98777578 |
Krishan_mishra7808 |
A |
Nov. 18, 2020, 5:51 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98776808 |
kojoker |
A |
Nov. 18, 2020, 5:39 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98776699 |
AEZAKMII |
A |
Nov. 18, 2020, 5:37 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98775492 |
monster_coder |
A |
Nov. 18, 2020, 5:16 a.m. |
OK |
GNU C++17 |
TESTS |
5 |
15 |
0 |
|
|
98770091 |
Sevatar |
A |
Nov. 18, 2020, 3:17 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98776972 |
erreeehhh |
A |
Nov. 18, 2020, 5:41 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98776634 |
rajneeshsharma |
A |
Nov. 18, 2020, 5:36 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98776215 |
alif_cse_ju |
A |
Nov. 18, 2020, 5:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98775878 |
vjudge2 |
A |
Nov. 18, 2020, 5:23 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98772890 |
Anus1373 |
A |
Nov. 18, 2020, 4:21 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98771808 |
julianferres |
A |
Nov. 18, 2020, 3:57 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98771121 |
SPyofgame |
A |
Nov. 18, 2020, 3:42 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98770686 |
M0riarty |
A |
Nov. 18, 2020, 3:32 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98770167 |
gameofcodes |
A |
Nov. 18, 2020, 3:19 a.m. |
OK |
GNU C++17 (64) |
TESTS |
5 |
15 |
0 |
|
|
98770215 |
bnurgeldiyev514 |
A |
Nov. 18, 2020, 3:20 a.m. |
OK |
Go |
TESTS |
5 |
46 |
102400 |
|
|
98767811 |
codelegend |
A |
Nov. 18, 2020, 2:15 a.m. |
OK |
Haskell |
TESTS |
5 |
31 |
102400 |
|
|
98769204 |
mohitn |
A |
Nov. 18, 2020, 2:54 a.m. |
OK |
Java 11 |
TESTS |
5 |
155 |
0 |
|
|
98751753 |
princewillz2013 |
A |
Nov. 17, 2020, 6:09 p.m. |
OK |
Java 11 |
TESTS |
5 |
155 |
0 |
|
|
98755912 |
rafee69029 |
A |
Nov. 17, 2020, 7:15 p.m. |
OK |
Java 11 |
TESTS |
5 |
156 |
0 |
|
|
98749066 |
sanju2504 |
A |
Nov. 17, 2020, 5:41 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
98751033 |
princewillz2013 |
A |
Nov. 17, 2020, 6 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
98750807 |
akshay0701 |
A |
Nov. 17, 2020, 5:58 p.m. |
OK |
Java 11 |
TESTS |
5 |
171 |
0 |
|
|
98751083 |
codebook_2000 |
A |
Nov. 17, 2020, 6:01 p.m. |
OK |
Java 11 |
TESTS |
5 |
186 |
0 |
|
|
98778337 |
kartikeysemwal |
A |
Nov. 18, 2020, 6:03 a.m. |
OK |
Java 11 |
TESTS |
5 |
186 |
0 |
|
|
98764613 |
onemin |
A |
Nov. 17, 2020, 11:58 p.m. |
OK |
Java 11 |
TESTS |
5 |
186 |
0 |
|
|
98749164 |
vishrut_goti6231 |
A |
Nov. 17, 2020, 5:42 p.m. |
OK |
Java 11 |
TESTS |
5 |
186 |
0 |
|
|
98751873 |
2020akadaver |
A |
Nov. 17, 2020, 6:11 p.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
98769715 |
sankcan55 |
A |
Nov. 18, 2020, 3:07 a.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
98762352 |
O-infinity |
A |
Nov. 17, 2020, 10:03 p.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
98754745 |
Avi_2506 |
A |
Nov. 17, 2020, 6:53 p.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
98747110 |
punit1999 |
A |
Nov. 17, 2020, 5:26 p.m. |
OK |
Java 8 |
TESTS |
5 |
93 |
0 |
|
|
98746024 |
rachitpts.2454 |
A |
Nov. 17, 2020, 5:21 p.m. |
OK |
Java 8 |
TESTS |
5 |
108 |
0 |
|
|
98752439 |
ujjwalavishek |
A |
Nov. 17, 2020, 6:18 p.m. |
OK |
Java 8 |
TESTS |
5 |
108 |
0 |
|
|
98747246 |
MartyByrde |
A |
Nov. 17, 2020, 5:27 p.m. |
OK |
Java 8 |
TESTS |
5 |
108 |
0 |
|
|
98743399 |
R3KT |
A |
Nov. 17, 2020, 4:48 p.m. |
OK |
Java 8 |
TESTS |
5 |
108 |
0 |
|
|
98775989 |
parascoding |
A |
Nov. 18, 2020, 5:25 a.m. |
OK |
Java 8 |
TESTS |
5 |
109 |
0 |
|
|
98735814 |
sevenander |
A |
Nov. 17, 2020, 4:31 p.m. |
OK |
Kotlin |
TESTS |
5 |
109 |
0 |
|
|
98760332 |
3bab |
A |
Nov. 17, 2020, 8:52 p.m. |
OK |
Kotlin |
TESTS |
5 |
124 |
0 |
|
|
98754047 |
koper |
A |
Nov. 17, 2020, 6:42 p.m. |
OK |
Kotlin |
TESTS |
5 |
155 |
0 |
|
|
98751092 |
horvat.kamca |
A |
Nov. 17, 2020, 6:01 p.m. |
OK |
Kotlin |
TESTS |
5 |
155 |
1740800 |
|
|
98774223 |
Datso |
A |
Nov. 18, 2020, 4:50 a.m. |
OK |
Kotlin |
TESTS |
5 |
155 |
1740800 |
|
|
98776567 |
phelka |
A |
Nov. 18, 2020, 5:35 a.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
30 |
0 |
|
|
98753683 |
MrS4g0 |
A |
Nov. 17, 2020, 6:36 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
31 |
0 |
|
|
98748653 |
MrS4g0 |
A |
Nov. 17, 2020, 5:37 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
31 |
0 |
|
|
98746588 |
Gravekper |
A |
Nov. 17, 2020, 5:23 p.m. |
OK |
MS C++ 2017 |
TESTS |
5 |
46 |
0 |
|
|
98743299 |
asutosh1998 |
A |
Nov. 17, 2020, 4:48 p.m. |
OK |
.NET Core C# |
TESTS |
5 |
93 |
0 |
|
|
98759248 |
tamahom |
A |
Nov. 17, 2020, 8:22 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
124 |
0 |
|
|
98773026 |
ananyalok4 |
A |
Nov. 18, 2020, 4:24 a.m. |
OK |
PyPy 3 |
TESTS |
5 |
124 |
0 |
|
|
98758208 |
sourabhgol1999 |
A |
Nov. 17, 2020, 7:59 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
124 |
0 |
|
|
98764620 |
vjudge1 |
A |
Nov. 17, 2020, 11:59 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
124 |
1433600 |
|
|
98750019 |
sary_28 |
A |
Nov. 17, 2020, 5:50 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
124 |
1536000 |
|
|
98760302 |
ebaalhuis |
A |
Nov. 17, 2020, 8:51 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
139 |
0 |
|
|
98737361 |
DhanushPrabha |
A |
Nov. 17, 2020, 4:35 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
139 |
0 |
|
|
98764616 |
Betcoin |
A |
Nov. 17, 2020, 11:58 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
139 |
1433600 |
|
|
98740805 |
sivaniuddaraju20 |
A |
Nov. 17, 2020, 4:43 p.m. |
OK |
PyPy 3 |
TESTS |
5 |
139 |
1536000 |
|
|
98772976 |
Coding_RDX |
A |
Nov. 18, 2020, 4:23 a.m. |
OK |
PyPy 3 |
TESTS |
5 |
140 |
0 |
|
|
98771087 |
sarthak0505 |
A |
Nov. 18, 2020, 3:41 a.m. |
OK |
Python 3 |
TESTS |
5 |
77 |
0 |
|
|
98762111 |
eugalt |
A |
Nov. 17, 2020, 9:53 p.m. |
OK |
Python 3 |
TESTS |
5 |
78 |
307200 |
|
|
98759584 |
Moondecoder |
A |
Nov. 17, 2020, 8:31 p.m. |
OK |
Python 3 |
TESTS |
5 |
78 |
307200 |
|
|
98762799 |
Umm...idk |
A |
Nov. 17, 2020, 10:23 p.m. |
OK |
Python 3 |
TESTS |
5 |
92 |
307200 |
|
|
98770871 |
Rashi30 |
A |
Nov. 18, 2020, 3:36 a.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
0 |
|
|
98753681 |
akshajj2004 |
A |
Nov. 17, 2020, 6:36 p.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
0 |
|
|
98753563 |
mjontop |
A |
Nov. 17, 2020, 6:35 p.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
0 |
|
|
98752474 |
sh1194 |
A |
Nov. 17, 2020, 6:19 p.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
0 |
|
|
98750764 |
kraspai |
A |
Nov. 17, 2020, 5:58 p.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
0 |
|
|
98747984 |
Manas_Gupta_813 |
A |
Nov. 17, 2020, 5:32 p.m. |
OK |
Python 3 |
TESTS |
5 |
93 |
0 |
|
|
98763598 |
ryad0m |
A |
Nov. 17, 2020, 11:03 p.m. |
OK |
Rust |
TESTS |
5 |
30 |
0 |
|
|
98752440 |
kobae964 |
A |
Nov. 17, 2020, 6:18 p.m. |
OK |
Rust |
TESTS |
5 |
31 |
409600 |
|
|
remove filters
Back to search problems