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
NISA [10]
3 years ago
12

There are n tasks to complete. Each task first needs to be preprocessed on a supercomputer and then finished on one of n process

ors. Task i requires pi seconds of preprocessing on the supercomputer followed by fi seconds on some processor to complete. Note that tasks are fed to the supercomputer sequentially but can be executed in parallel on different processors once they have been preprocessed. The process terminates when all tasks have been completed. The duration of the process is the total time until termination. Give an efficient algorithm that determines an ordering of the tasks for the supercomputer that minimizes the duration of the process, as well as the minimum duration.
Computers and Technology
1 answer:
evablogger [386]3 years ago
7 0

Answer:

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

ll i,n,j,s;

cout<<"Enter size of array: ";

cin>>n;

ll a[n];

cout<<"Enter elements of array: ";

s=0;

for(i=0;i<n;i++)

{

cin>>a[i];

s+=a[i];

}

if(s%3!=0)

{

cout<<"No";

return 0;

}

ll dp[n][s/3+1];

for(i=0;i<=s/3;i++)

{

if(i==a[0])

dp[0][i]=1;

else

dp[0][i]=0;

}

for(i=0;i<n;i++)

dp[i][0]=1;

for(i=1;i<n;i++)

for(j=0;j<=s/3;j++)

{

if(j<a[i])

dp[i][j]=dp[i-1][j];

else

dp[i][j]=dp[i-1][j]||dp[i-1][j-a[i]];

}

if(dp[n-1][s/3]==0)

{

cout<<"No";

return 0;

}

ll vis[n];

for(i=0;i<n;i++)

vis[i]=0;

ll curr=s/3;

ll indx=n-1;

ll c=0;

while(indx>0)

{

if(dp[indx][curr]==1&&(curr-a[indx]>=0&&dp[indx-1][curr-a[indx]]==1))//include indx

{

vis[indx]=1;

curr=curr-a[indx];

c++;

}

indx--;

}

if(dp[0][curr]==1){

vis[0]=1;

c++;}

ll b[n-c];

ll k=0;

for(i=0;i<n;i++)

{

if(vis[i]==0)

b[k++]=a[i];

}

ll dp1[k][s/3+1];

for(i=0;i<=s/3;i++)

{

if(i==b[0])

dp1[0][i]=1;

else

dp1[0][i]=0;

}

for(i=0;i<k;i++)

dp1[i][0]=1;

for(i=1;i<k;i++)

for(j=0;j<=s/3;j++)

{

if(j<b[i])

dp1[i][j]=dp1[i-1][j];

else

dp1[i][j]=dp1[i-1][j]||dp1[i-1][j-b[i]];

}

if(dp1[k-1][s/3]==0)

{

cout<<"No";

return 0;

}

else

cout<<"Yes";

}

Explanation:

You might be interested in
Which director has shot a movie in HD? George Lucas, Michael Mann, Michael Moore, none of the above, all of the above
levacccp [35]

This answer is All of the above.

8 0
3 years ago
When you add an rss feed to hootsuite publisher, posts from blogs and websites you designate will be?
Cloud [144]

All answers are correct.

Source and explanation: certificationanswers.com/en/category/hootsuite-platform/

8 0
3 years ago
If you ping a device, you are using the______protocol
meriva
Joystick..................:-)
6 0
3 years ago
____ is one of the primary operations of a computer.
Romashka [77]
Processing <span>is one of the primary operations of a computer.</span>
7 0
3 years ago
Which of the following should NOT be done to keep people from slipping on floors? A) Have the proper absorbents in an easy-to-fi
RoseWind [281]

The following options helps keep people from slipping on floors

A) Have the proper absorbents in an easy-to-find place to quickly put on spills : So that accidental little spills can be cleaned right away.

C) Wear slip-resistant footwear : It is a precautionary step to follow, no matter where we go.

D) Mark a slippery area with an easy-to-use tent sign that says " Caution, Slippery floor" : This allows people to be aware of the wet area and cross it cautiously.

Leaving oil and fluids to air dry thoroughly, takes a long time and there are chances that people step over it and slip.

So, the answer is

(B) Anytime oil or fluids are spilled on the floor, leave them to thoroughly air dry.

8 0
3 years ago
Read 2 more answers
Other questions:
  • In fiberoptic cable, the signal source is__________waves
    7·1 answer
  • Which of the following is the best definition of a workplace policy?
    13·2 answers
  • ________ is a computer-based network that triggers actions by sensing changes in the real or digital world.
    15·2 answers
  • Edie wants to visit her university's website. What software application should she use?
    9·2 answers
  • Interstate highway numbers Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 of 95) go north/south, an
    8·1 answer
  • What is problem scoping
    14·1 answer
  • 9. Lael wants to determine several totals and averages for active students. In cell Q8, enter a formula using the COUNTIF functi
    9·1 answer
  • I NEED THIS ASAP PLS
    12·1 answer
  • Which of the following is not a bus type A. Address bus B. Data bus C. Memory bus D. Control bus ​
    7·2 answers
  • You have been elected to assist the school's yearbook committee and newspaper club in purchasing new computers. The current comp
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!