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
To join a social network you create an avatar true or false
svp [43]
False because not all social media webstites provide avatars
7 0
3 years ago
Read 2 more answers
Write a Python 3 program to read from a .csv file containing rates from power companies. Your program should determine the avera
aliya0001 [1]

Answer:

In python:

file = open("rates.csv", "r")

ratecount = 0

ratesum = 0

mylist = []

rates = file.readlines()

for nums in rates:

     num = nums.rstrip('\n')

     mylist.append(int(num))

     for i in num:

           ratesum= ratesum + int(i)

           ratecount = ratecount + 1

print("Maximum Rate: "+str(max(mylist)))

print("Minimum Rate: "+str(min(mylist)))

print("Average Rate: "+str(ratesum/ratecount))

Explanation:

This opens the csv file

file = open("rates.csv", "r")

This initializes the number of rates in the file

ratecount = 0

This initializes the sum of the rates

ratesum = 0

This initializes an empty list

mylist = []

This reads the rates into lines

rates = file.readlines()

This iterates through the rates (as a string)

for nums in rates:

This removes the newline character \n in the rates

     num = nums.rstrip('\n')

This appends the rates (as an integer) to the empty list

     mylist.append(int(num))

The following counts the rates in the file and also sum them up

<em>      for i in num: </em>

<em>            ratesum= ratesum + int(i) </em>

<em>            ratecount = ratecount + 1 </em>

This prints the maximum of the rates

print("Maximum Rate: "+str(max(mylist)))

This prints the minimum of the rates

print("Minimum Rate: "+str(min(mylist)))

This calculates and prints the average rate

print("Average Rate: "+str(ratesum/ratecount))

6 0
2 years ago
Investigate the many ways that hardware and software can cause an interrupt to occur. Are ALL interrupts treated equally or do s
slavikrds [6]

Answer:

Following are the responses to the given question:  

Explanation:

This list is based mostly on the processor. Then you'll be ordered. An interrupt of a particular cable (wire) is produced for PC-ish CPUs (IRQ 0 - 31 for some intel processors). The bigger challenge is a lower number.

Strange factors have included a system clock, power business, 0, some reserved for use by CPU testing, serial/parallel/... ports and also some terminated/error/state/new devices requests device Thus a key touch on the keyboards could create an interrupt that was direct on old devices.

3 0
2 years ago
An employee sets up an automation that transfers files in a specific folder on their PC to a remote drive for archiving, provide
Yuri [45]

Answer:

Rule based automation

Explanation:

8 0
2 years ago
What is administrator access? Multiple Choice refers to how quickly a system can transform to support environmental changes perf
IrinaVladis [17]

Answer:

Administrator access is:

refers to the varying levels that define what a user can access, view, or perform when operating a system refers to the time frames when the system is operational

Explanation:

The reasons behind this answer are that in the first place the administrator role is the maximum role an account can have in the operating system. Controlling the different levels of access the rest of the accounts can have on the system. It then is a hierarchical role, not the changes someone can execute in a certain environment, these are called rules.

3 0
2 years ago
Other questions:
  • People who work the total hours for which they get paid have
    7·2 answers
  • ​PeroxyChem's IT staff was able to free its IT staff to spend less time on routine maintenance and more time on strategic tasks
    11·1 answer
  • A hard drive cannot be partitioned until the device _________ is set.
    15·1 answer
  • ​For complex models, analysts can choose computer-based modeling tools that use _____, which includes standard shapes and symbol
    10·1 answer
  • What is the safest way to shut down a desktop or laptop computer?
    8·1 answer
  • All of the following are helpful test taking strategies EXCEPT_______________.
    5·2 answers
  • Which statements about organizing messages in Outlook 2016 are true? Check all that apply. The Categories function is used for g
    13·2 answers
  • How would you define the term technology
    8·1 answer
  • What does a for loop look for in the sequence of data? Check all that apply.
    6·2 answers
  • YASHARI earns $27,000 per year, is single, and lives in Wyoming. She has $7000 in Direct Subsidized loans and another $19,000 in
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!