Question: in java or c++, complete the function below, kindly consider the constraints also New Year is approaching, and Tim, the tortoise, needs to prepare n

in java or c++, complete the function below, kindly consider the constraints also  in java or c++, complete the function below, kindly consider the
constraints also New Year is approaching, and Tim, the tortoise, needs to
prepare n fruit cakes for the kids in the neighborhood. Baking cake
is easy (at least for Tim), you first need to prepare the
batter and then bake it. To prepare the ith cake, it takes
A[i] time to make the batter and B[i] time to bake, no
time is lost in any other process. Tim has a large oven,
which allows him to bake several cakes simultaneously, but he can only
make the batter for a cake one at a time. Being the

New Year is approaching, and Tim, the tortoise, needs to prepare n fruit cakes for the kids in the neighborhood. Baking cake is easy (at least for Tim), you first need to prepare the batter and then bake it. To prepare the ith cake, it takes A[i] time to make the batter and B[i] time to bake, no time is lost in any other process. Tim has a large oven, which allows him to bake several cakes simultaneously, but he can only make the batter for a cake one at a time. Being the fastest tortoise. Tim wants to do everything quickly, Come up with a strategy that allows Tim to finish making all these cakes as soon as possible Input Format The first line contains an integer, n denoting the number of elements in A and B Each line i of the n subsequent lines (where sun) contains an integer describing Ali Input Format The first line contains an integer, n, denoting the number of elements in A and B. Each line i of the n subsequent lines (where 0 Si 3:54 10 3 11 un A = {5, 1, 1} B = {4, 10,9} The optimal order is: 2nd (1, 10)-> 3rd (1,9)-> 1st (5,4) 1 1 4 10 9 62 6 The minimum time required is 62 & 14 8 12 1 19 -4 Languages. Python 3 Java, C+ + Scala Go Per Bash Plain JavaScript.R.PHP.Ruby Python Cloure minimum time red is 52 Select theme 1 inciude bits stoc++.h> 2 using namespace std; 3 int fastestcakes(vector A, vector int> B){ } 5 int main(){ $ night int n; cin>>n 10 vectorcint> A(n); for(int j = 0;j >A[j]; 12 } 1 16 vectorcint> B(n); for(int j = 0;j >B[j]; 15 Reco n; 9 cin>>n; vector int> A(n); for(int j = 0; j >A[j]; } vector int> B(n); for(int j = 0; j >B[j]; int result; result = fastestcakes(A,B); cout

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!