Travel Pass | Codechef September long challenge 2021 | Travel Pass Solution

 

Codechef September long challenge 2021 | Travel Pass Solution






                                    Scorable Problems for Division 3



2 Problem. 

Travel Pass Problem Code: TRAVELPS Submit

Read problem statements in BengaliMandarin ChineseRussian, and Vietnamese as well.

Chef is going on a road trip and needs to apply for inter-district and inter-state travel e-passes. It takes AA minutes to fill each inter-district e-pass application and BB minutes for each inter-state e-pass application.

His journey is given to you as a binary string SS of length NN where 00 denotes crossing from one district to another district (which needs an inter-district e-pass), and a 11 denotes crossing from one state to another (which needs an inter-state e-pass).

Find the total time Chef has to spend on filling the various forms.

Input Format

·        The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.

·        Each test case contains two lines of input.

·        First line contains three space separated integers N,AN,A and BB.

·        Second line contains the string SS.

Output Format

For each testcase, output in a single line the total time Chef has to spend on filling the various forms for his journey.

Constraints

·        1≤T≤1021≤T≤102

·        1≤N,A,B≤1021≤N,A,B≤102

·        Si∈{0,1}Si{′0′,′1′}

Subtasks

Subtask #1 (100 points): original constraints

Sample Input 1 

3

2 1 2

00

2 1 1

01

4 2 1

1101

Sample Output 1 

2

2

5

Explanation

Test case 11: Chef needs total 22 inter-district e-passes, and he will be filling them in total 1⋅2=212=2 minutes.

Test case 33: Chef needs total 11 inter-district e-pass and 33 inter-state e-passes, and he will be filling them in total 2⋅1+1⋅3=521+13=5 minutes.

Author:daanish_adm

Date Added:30-08-2021

Time Limit:0.5 secs

Source Limit:50000 Bytes

Languages:CPP14, C, JAVA, PYTH 3.6, CPP17, PYTH, PYP3, CS2, ADA, PYPY, TEXT, PAS fpc, NODEJS, RUBY, PHP, GO, HASK, TCL, PERL, SCALA, LUA, kotlin, BASH, JS, LISP sbcl, rust, PAS gpc, BF, CLOJ, R, D, CAML, FORT, ASM, swift, FS, WSPC, LISP clisp, SQL, SCM guile, PERL6, ERL, CLPS, ICK, NICE, PRLG, ICON, COB, SCM chicken, PIKE, SCM qobi, ST, SQLQ, NEM

 

Solution in Python 3

# cook your dish here

t= int(input())

while(t):

    n,a,b = map(int, input().split(' '))

    s = input()

    otp = s.count('0')*a + s.count('1')*b

    print(otp)

    t-=1

Comments

Popular posts from this blog

The Old Saint And Three Questions Problem Code: THREEQ

Airline Restrictions Solution September Challenge 2021 (Rated for Div 3)

Minimize Digit Sum Solution | Codechef September long challenge 2021

Maximise the Subsequence Sum Problem Code: SIGNFLIP Codechef Solution

10 things you need to know about SpaceX

THE TOP 10 PAID BLOGGERS IN 2020

THE TOP 10 YOUTUBERS IN 2020

2-D Point Meeting Solution | Codechef September long challenge 2021

Say No To Drugs Problem Code: NODRUGS