Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please read the question carefully and don't repeat my code without any edit ! (that what happened to my previous submission!) Help me to revise

Please read the question carefully and don't repeat my code without any edit ! (that what happened to my previous submission!)

Help me to revise the code that uses dynamic programming to solve this problem!

this is" the fifth time" that I upload this question without getting a good answer :)

(the previuos solutions eaither to be incomplete python code because of long steps, or not using dynamic programming, or repeat my code! )

the problem: image text in transcribed

Python code:

image text in transcribed

got:

240 for first input , but 500 instead of 580 for the second input!

input: standard input output: standard output The Computer Science department keeps getting larger, and our department has more and more undergraduate students and graduate students every year. Eventually, the department decided to partition CS 287; Colloquium in Computer Science, into two sections since otherwise no classroom is big enough for all students. Yihan is running CS 287 now. Yihan has lots of experience on running the colloquium. She categorized the speakers based on their research areas: theory. system, and Al. The students don't like to attend talks in the same category consecutively. More precisely, the students will consider this talk and the two previous talks (or fewer if there haven't been that many), and: - If they are in same category, students will only pay attention to the talk for 20 minutes. - If they are from two categories, students will pay attention to the talk for 40 minutes. - If they are all from three different categaries, students will pay aftention to the talk for the entire 60 minutes. Yihan has contacted n prominent computer scientists to give the talks. Of course, the speakers are busy, so they have committed s certain day to give the talk. Yihan knows the order, and her task is to determine which speaker should go to which section. The speakers do not like to give the same talk twice, so Yihan can only assign himvher to one of the sections. Input The first line contains an integer n(1n100,000). The second line contains a string consisting of n characters, indicating the speakers research areas in the order their taiks. Each character will be one of the uppercase letters ' T ' (for theory). ' S ' (for systern) or ' A ' (for A ). Output The output contains only one number, the total time (in minutes) that the students will pay attention to for both sections. The two sections can have different numbers of speakers

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

this is for c++ -24 % 5 is _____

Answered: 1 week ago