Skip to content

Commit 159f799

Browse files
corrected code
worker.at(current_worker)[2] index 1 might be giving you the correct answer but in the vector with size 3, cost is stored at the second index, not area per unit. Please look carefully at the proposed changes.
1 parent 5dfd484 commit 159f799

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Greedy/FractionalKnapsack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ long long go(vector<vector<long long>> worker, long long area){
5252
// cout << "Worker: "<<current_worker << '\n';
5353
// cout << "Timegap: "<<time_gap << '\n';
5454

55-
area_done += time_gap*(worker.at(current_worker)[1]);
55+
area_done += time_gap*(worker.at(current_worker)[2]);
5656

5757
// cout <<"Cost: "<<cost<< '\n';
5858
// cout <<"Area done: "<<area_done<< '\n'<<endl;

0 commit comments

Comments
 (0)