Question: Based on UVA Online Judge Problem #11608. Programming contests are being arranged so frequently these days. While this might be a good news for the

Based on UVA Online Judge Problem #11608.

Programming contests are being arranged so frequently these days. While this might be a good news for the contestants, the scenario is completely opposite for the problemsetters. So far, the problemsetters somehow managed to produce enough and say "No problem!". But it is doubtful how long will it be possible if the trend of arranging contests on short notice continues.

You are given the number of problems created in every month of a year and number of problems required in each month. If NNproblems are required in a month and there are not enough problems at that time, all contests that month are canceled. Write a program to determine if there are enough problems for the contests. Please keep in mind that if a problem is created in month XX, it can only be used in month X+1X+1 and later months.

Your work

Write a function vector noProblem(int start, vector created, vector needed). Variable start contains the number of problems ready at the beginning of the year. Vector created denotes the number of problems created in each of the 12 months of that year. Vector needed denotes the number of problems required for use in contests in those 12 months.

Output a vector showing for each month if there are enough problems. If there are enough problems for a month, set the value to No problem! :D. If there are not enough problems for the month, set it to No problem. :(.

Example

For this input:

start = 5 created = {3, 0, 3, 5, 8, 2, 1, 0, 3, 5, 6, 9} needed = {0, 0, 10, 2, 6, 4, 1, 0, 1, 1, 2, 2} 

The result would be:

No problem! :D No problem! :D No problem. :( No problem! :D No problem! :D No problem! :D No problem! :D No problem! :D No problem! :D No problem! :D No problem! :D No problem! :D 

main.cpp:

#include #include #include

using namespace std;

#include "NoProblem.cpp"

int main() {

int start = 5; vector created = {3, 0, 3, 5, 8, 2, 1, 0, 3, 5, 6, 9}; vector needed = {0, 0, 10, 2, 6, 4, 1, 0, 1, 1, 2, 2};

vector result = NoProblem(start, created, needed);

for(vector::iterator it = result.begin(); it != result.end(); it ++) cout << *it << endl; }

startwith:

vector NoProblem(int start, vector created, vector needed) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!