Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I had a coding problem. I wrote the following code to attempt to solve it. #include #include #include #include #include using namespace std; int main()

image text in transcribed

I had a coding problem. I wrote the following code to attempt to solve it.

#include #include #include #include #include

using namespace std;

int main() { string line; getline(cin, line); stringstream ss(line); int numDays, price; ss >> numDays >> price;

int totalCost = 0; vector days(numDays); vector inBetween(numDays - 1);

getline(cin, line); ss = stringstream(line); for (int i = 0; i > days[i]; }

if (numDays == 1) { totalCost += price + 1; } else { totalCost += price + 1; for (int i = 0; i price + 1) { totalCost += price + 1; } else { totalCost += inBetween[i]; } } }

cout

However 10/12 of the test cases written show it as giving the wrong output. Can someone help me?

1N105 ) days that she will watch Mooloo. Because Mooloo is a paid subscription service, she now needs to decide how to minimize the amount of money she needs to pay. Mooloo has an interesting subscription system: it costs d+K(1K109) moonies to subscribe to Mooloo for d consecutive days. You can start a subscription at any time, and you can start a new subscription as many times as you desire if your curren subscription expires. Given this, figure out the minimum amount of moonies Bessie needs to pay to fulfill her schedule. INPUT FORMAT (input arrives from the terminal / stdin): The first line contains integers N and K. The second line contains N integers describing the days Bessie will watch Mooloo: 1d1

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

Ty e2y Evaluate the integral dy

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago