Submission #41744829


Source Code Expand

x,y,z=map(int,input().split())
s=input()
n=len(s)
dp=[[0]*2 for _ in range(n+1)]
dp[0][0]=0
dp[0][1]=10**18
for i in range(1, n+1):
    if s[i-1] == "a":
        dp[i][0]=min(dp[i-1][0]+x, dp[i-1][1]+min(x,y)+z)
        dp[i][1]=min(dp[i-1][1]+y, dp[i-1][0]+min(x,y)+z)
    else:
        dp[i][0]=min(dp[i-1][0]+y, dp[i-1][1]+min(x,y)+z)
        dp[i][1]=min(dp[i-1][1]+x, dp[i-1][0]+min(x,y)+z)

print(min(dp[n]))

Submission Info

Submission Time
Task D - Shift vs. CapsLock
User Yuroru
Language Python (3.8.2)
Score 400
Code Size 428 Byte
Status AC
Exec Time 562 ms
Memory 64064 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 01_small_09.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 02_rnd_06.txt, 02_rnd_07.txt, 02_rnd_08.txt, 02_rnd_09.txt, 03_max_00.txt, 03_max_01.txt, 03_max_02.txt, 03_max_03.txt, 04_border_00.txt, 04_border_01.txt, 04_border_02.txt, 04_border_03.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 19 ms 8876 KiB
00_sample_01.txt AC 17 ms 8876 KiB
00_sample_02.txt AC 17 ms 8868 KiB
01_small_00.txt AC 22 ms 9032 KiB
01_small_01.txt AC 18 ms 8956 KiB
01_small_02.txt AC 21 ms 8868 KiB
01_small_03.txt AC 19 ms 8864 KiB
01_small_04.txt AC 18 ms 8976 KiB
01_small_05.txt AC 18 ms 8972 KiB
01_small_06.txt AC 18 ms 8920 KiB
01_small_07.txt AC 21 ms 8856 KiB
01_small_08.txt AC 17 ms 8976 KiB
01_small_09.txt AC 23 ms 8848 KiB
02_rnd_00.txt AC 531 ms 53852 KiB
02_rnd_01.txt AC 484 ms 57236 KiB
02_rnd_02.txt AC 473 ms 54608 KiB
02_rnd_03.txt AC 380 ms 45968 KiB
02_rnd_04.txt AC 388 ms 48268 KiB
02_rnd_05.txt AC 355 ms 43892 KiB
02_rnd_06.txt AC 393 ms 42800 KiB
02_rnd_07.txt AC 302 ms 38908 KiB
02_rnd_08.txt AC 446 ms 47144 KiB
02_rnd_09.txt AC 293 ms 38112 KiB
03_max_00.txt AC 546 ms 63760 KiB
03_max_01.txt AC 550 ms 63764 KiB
03_max_02.txt AC 557 ms 63948 KiB
03_max_03.txt AC 551 ms 64064 KiB
04_border_00.txt AC 538 ms 63776 KiB
04_border_01.txt AC 548 ms 63872 KiB
04_border_02.txt AC 542 ms 63908 KiB
04_border_03.txt AC 562 ms 63952 KiB