One constraint present in all heuristics discussed in class is that one person c
ID: 3604397 • Letter: O
Question
One constraint present in all heuristics discussed in class is that one person cannot be assigned more than one task. Consider a scenario where this constraint is relaxed (i.e. one person can be assigned multiple (or zero) tasks). Develop a heuristic in pseudocode and write a Python program that tries to minimize the total cost, where each task must be assigned exactly once and each person can be assigned multiple (or zero) tasks. Call your code lap_h5.py. Run this program with a 200x200 csv file represent 200 people and 200 tasks. Display your results in a table on your Word document similar to the one below.
Problem Instance H5 4 5Explanation / Answer
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 105;
int A[MAX];
int main()
{
int T, N, numberOfThings = 0, currentTime = 0;
cin >> N >> T;
for(int i = 0;i < N;++i)
cin >> A[i];
sort(A, A + N);
for(int i = 0;i < N;++i)
{
currentTime += A[i];
if(currentTime > T)
break;
numberOfThings++;
}
cout << numberOfThings << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.