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
What kind of memory modules include registers between the system’s memory controller and the module’s memory chips, registers th
Nookie1986 [14]

Answer: Buffered

Explanation: Buffered memory is the memory contains registers between the modules of dynamic random access memory(DRAM).It is also known as registered memory. The purpose of using buffered memory to increase the stability and decrease the electrical load.

Other options are incorrect because ECC(error correcting code)memory is for correction and detection of incorrect data, non- parity memory is that don't utilize ECC module and multi-channel used for the increment in the rate of transmission between memory controller and DRAM.

Thus,the correct option is option buffered memory because of serial communication pattern with memory controller and parallel communication technique with chips .

4 0
3 years ago
Read 2 more answers
Consider the following program segment. ifstream inFile; //Line 1 int x, y; //Line 2 ... //Line 3 inFile &gt;&gt; x &gt;&gt; y;
MrMuchimi

Answer:

inFile.open("progdata.dat");

Explanation:

This command opens the file which is passed to it as an argument. We are quite used to the C++'s cin and cout functions contained in iostream library for reading and writing data, however, when working will real-life stuff, we find ourselves working with huge data saved as separate files and require our programs to read them, manipulate them and possibly write back to the files... The first operation usually carried out before a file can be read or written to is open

6 0
3 years ago
I was able to solve the question :))
Leviafan [203]

Answer:

ill take the points anyway

Explanation:

4 0
3 years ago
A microphone is a type of electronic.<br><br> True/Faulse
GenaCL600 [577]
Yes, True, a microphone IS a type of electronic
4 0
3 years ago
Only numbers should go in the columns for Payload Size and Packet Size. The sizes are in bytes. Don't forget to account for the
Anna11 [10]

Answer:

Non-Payload Bytes sent are 1476(total) - 393 (payload) = 1083 bytes

1083 (non-payload) out of 1476(total) is 73.37 %

Non-Hello bytes sent are 1476(total) - 53(hello payload) = 1425 bytes

1425(non-hello) out of 1476(total) is 96.54 %

7 0
3 years ago
Other questions:
  • Food is shipped thousands of miles throughout our country using various types of transportation such as trucks, planes, and boat
    10·1 answer
  • Book checkout scenario at a library: The Worker tells the System the identity of a patron who wishes to check out books. The Sys
    8·1 answer
  • What is a difference between a waxing crescent and a waning gibbous? (1 point) waxing crescent: first quarter waning gibbous: th
    11·1 answer
  • You are the head of the corporate security department, and the Microsoft teamhas asked you for some assistance in setting the pa
    11·1 answer
  • Write a function that takes as input a single integer parameter n and computes the nth Fibonacci Sequence number. The Fibonacci
    8·1 answer
  • 9. Which of the following is the<br>leading use of computer?​
    13·1 answer
  • Paisa pay is facilitated in which e commerce website​
    15·1 answer
  • FILL IN THE BLANK.
    10·1 answer
  • Write a function sumOfMultiples, that inputs two integers - seed and cap. The function should return the sum of all the multiple
    6·1 answer
  • Kinda strange, and im good
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!