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