Ramesh Game

QUESTION

Ramesh is a hard-working employee.Seeing his dedication towards his work his boss decided to promote him. Ramesh was overjoyed on getting to know this.But soon he realized he needed to shift to another Town X. Ramesh needed to transport his n boxes to Town X for which he contacted the company \”Packers and Movers\”.This company sent him m trucks.Each truck took 1 hour to go from his house to Town X and another 1 hour to return.But each truck could carry only 1 box at a time and also each truck has a limit for the maximum weight of the box it can carry.A truck can be used multiple times. Since Ramesh is busy he gives you the job for finding the minimum time in which he can transfer all his n boxes to Town X.\n\nINPUT\nThe first line contains 2 integers n and m.The next line contains n integers denoting the weight of each box.This is followed by a line containing m integers denoting the maximum capacity of each truck.\n\nOutput\nPrint the minimum time to transfer all the boxes to Town X.

“TESTCASE_1”: “7 2\n10 2 16 19 6 11 5\n29 25\n###—###SEPERATOR—###—\n7”, “TESTCASE_2”: “5 3\n2 5 2 4 7\n6 8 9\n###—###SEPERATOR—###—\n3”, “TESTCASE_3”: “9 4\n5 4 7 9 7 1 2 5 6\n9 4 3 7\n###—###SEPERATOR—###—\n5”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include<stdio.h>
int main()
{
   
	long int a[100000],b[100000];
	int i,m,n,d,r;
 
	    scanf("%d %d",&n,&m);
	    for (i=0;i<n;i++)
	    scanf("%ld",&a[i]);
	      for (i=0;i<m;i++)
	      scanf("%ld",&b[i]);
	      d=n/m;
	      d=d*2;
	      r=n%m;
	      if(r<=m)
	      {
	      	d=d+1;
		  }
	      printf("%d",d);
  return 0;
}

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.