Computer Science, asked by 17211a05g2, 9 months ago

A big group of students, starting a long journey on different set of vehicles need to fill petrol in their vehicles. As group leader you are required to minimize the time they spend at the petrol pump to start the journey at the earliest. You will be given the quantity of petrol (in litres) that can be filled in each vehicle. There are two petrol vending machines at the petrol pump. You need to arrange the vehicles in such a way that they take shortest possible time to fill all the vehicles and provide the time taken in seconds as output. Machine vends petrol @ 1litre/second. Assume that there is no time lost between switching vehicles to start filling petrol.

Answers

Answered by teja13757
0

Answer:

just need 5min

Explanation:

easy there are two vending pumps so one will be operated by vender one by leader

Answered by sharipriya311099
0

Answer:

#include<bits/stdc++.h>

using namespace std;

int maxi = INT_MAX;

int maxx(int a, int b)

{  

   return (a > b)?a:b;

}

void cal_Time(int total, int sum, int i, vector<int> v1)

{  

   if(maxx(sum, total-sum) < maxi)  

   {  

       maxi = maxx(sum, total-sum);  

   }  

   if(v1[i])  

       return;  

   cal_Time(total, sum + v1[i], i+1, v1);  

   cal_Time(total, sum, i+1, v1);  

   return;

}

int main()

{  

   int n, i = 1, sum=0;

   string s;  

   vector<int> v1;  

   getline(cin, s, '\n');  

   stringstream ss(s);  

   while(ss>>n)  

   {  

       sum+=n;  

       v1.push_back(n);  

   }  

   cal_Time(sum, 0, 0, v1);  

   cout<<maxi;

}

Explanation:

Similar questions