1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Stells [14]
2 years ago
11

A friend of Alex has gifted a movie collection, and Alex is excited to watch them all as quickly as possible. The duration of th

e movies is given in array durations[n], where n is the number of movies, and each movie duration lies between 1.01 and 3.00 units of time (up to two decimal places). Every day, Alex wants to spend no more than 3.00 units of time watching the movies but also wants to complete the movies in the least number of days possible. Alex does not leave a movie in between. That is, if Alex has picked up a movie, Alex watches the complete movie on the same day. Find the minimum number of days needed to watch all the movies.
Computers and Technology
1 answer:
marishachu [46]2 years ago
8 0

To find out the duration of alex's movies, you can use the code in C++ to make this calculation, where you will only need the number of movies and their duration, as well:

<h3>Writing code in C++:</h3>

<em>#include<bits/stdc++.h></em>

<em>using namespace std;</em>

<em>struct Movie {</em>

<em>   int timeBegin, duration, timeEnd;</em>

<em>   bool operator<(const Movie& another) const {</em>

<em>      return timeEnd < another.timeEnd;</em>

<em>   }</em>

<em>};</em>

<em>struct Festival {</em>

<em>   int count;</em>

<em>   vector<Movie> movies;</em>

<em>};</em>

<em>Festival* initialize(int timeBegin[], int duration[], int count) {</em>

<em>   Festival* filmFestival = new Festival;</em>

<em>   filmFestival->count = count;</em>

<em>   for (int i = 0; i < count; i++) {</em>

<em>      Movie temp;</em>

<em>      temp.timeBegin = timeBegin[i];</em>

<em>      temp.duration = duration[i];</em>

<em>      temp.timeEnd = timeBegin[i] + duration[i];</em>

<em>      filmFestival->movies.push_back(temp);</em>

<em>   }</em>

<em>   return filmFestival;</em>

<em>}</em>

<em>int solve(Festival* fest) {</em>

<em>   int res = 0;</em>

<em>   sort(fest->movies.begin(), fest->movies.end());</em>

<em>   int timeEnd = -1;</em>

<em>   for (int i = 0; i < fest->count; i++) {</em>

<em>      if (fest->movies[i].timeBegin >= timeEnd) {</em>

<em>         res++;</em>

<em>            timeEnd = fest->movies[i].timeEnd;</em>

<em>      }</em>

<em>   }</em>

<em>   return res;</em>

<em>}</em>

<em>int main(int argc, char *argv[]) {</em>

<em>int timeBegin[] = {1, 3, 0, 5, 5, 8, 8};</em>

<em>int duration[] = {3, 2, 2, 4, 3, 2, 3};</em>

<em>Festival * fest;</em>

<em>fest = initialize(timeBegin,duration, 7);</em>

<em>cout << solve(fest) << endl;</em>

<em>return 0;</em>

<em>}</em>

See more about C Code at brainly.com/question/17544466

#SPJ1

You might be interested in
What year did bill gates form traf-o-data?
alexgriva [62]

In 1972 Bill Gates formed Traf-O-Data.

8 0
3 years ago
The modulus ( % ) actually gives you the ___________ of an integer division problem.
Svetlanka [38]
The answer is (e) sum
7 0
4 years ago
Write a program that outputs "Hello World!" For ALL labs, end with newline (unless otherwise stated).
Vesnalui [34]

The program that output "Hello World " is represented as follows:

print("Hello World")

<h3 /><h3>Code explanation:</h3>

The code is written in python.

We use the print statement to print out the string word "Hello world".

When the code is run, the output of the code will be "Hello world".

"Hello world" is a string.

learn more on python code here: brainly.com/question/21497685?referrer=searchResults

8 0
3 years ago
Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "To
Ludmilka [50]

Answer:

#include <iostream>

using namespace std;

void PrintPopcornTime (int bagOunces){

   if (bagOunces < 2){

       cout << "Too small"<<endl;

   }

   else if (bagOunces > 10){

       cout << "Too large"<<endl;

   }

   else{

       cout << bagOunces*6 <<" seconds"<<endl;

   }

}

int main(){

   PrintPopcornTime(7);

   

   return 0;

}

Explanation:

Create a function called PrintPopcornTime that takes one parameter, bagOunces

Check the bagOunces using if-else structure. If it is smaller than 2, print "Too small". If it is greater than 10, print "Too large". Otherwise, calculate and print 6*bagOunces followed by " seconds".

Call the function in the main function with parameter 7. Since 7 is not smaller than 2 or not greater than 10, "42 seconds" will be printed.

4 0
3 years ago
What do HIPAA guidelines protect?
Kruka [31]

Answer:

They protect patient medical records im pretty sure

Explanation:

7 0
3 years ago
Other questions:
  • Which of the following filenames is acceptable on both Windows and Mac<br> operating systems?
    9·1 answer
  • Everfi module 7 answers
    6·1 answer
  • Which of these browsers was the first widely adopted?
    12·1 answer
  • Which skill refers to the ability to visualize and implement possible business solutions to problems?
    6·1 answer
  • Question 16 of 20
    12·2 answers
  • Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet?
    15·1 answer
  • The Apple iPhone was a revolutionary product when it was introduced in 2007. To what extent do you agree or disagree with this s
    8·1 answer
  • Privacy Group of answer choices must be respected if we are to function as complete, self-governing agents is an absolute value
    5·1 answer
  • Why do people on Brainly verify answers that are wrong. I got 90% and 80% percent on my tests because of it
    6·2 answers
  • Fill in the blank with the correct response.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!