Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pytone code please solve using dynamic programming time limit per test: 1 second O memory limit per test: 256 megabytes input: standard input output: standard

pytone code please solve using dynamic programming

image text in transcribed

time limit per test: 1 second O memory limit per test: 256 megabytes 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 categories, students will pay attention 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 a 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 him/her 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 talks. Each character will be one of the uppercase letters ' T ' (for theory), 'S' (for system) or ' A ' (for Al). 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

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Determine the purpose of disability insurance.

Answered: 1 week ago

Question

Design a health and safety policy.

Answered: 1 week ago