Chef and Work SOLUTIONS CHEFNWRK

Chef and Work SOLUTIONS CHEFNWRK

Chef expert has N little boxes organized on a line from 1 to N. For each substantial I, the heaviness of the I-th box is Wi. Culinary expert needs to carry them to his home, which is at the position 0. He can hold quite a few boxes simultaneously; be that as it may, the all out weight of the containers he’s holding must not surpass K whenever, and he can possibly pick the ith box if all the cases between Chef’s home and the ith box have been either moved or gotten in this excursion. 
 
Thusly, Chef will get boxes and convey them home in at least one trips there and back. Locate the most modest number of trips there and back he needs or establish that he can’t bring all cases home. 
 
Info 
 
The principal line of the info contains a solitary number T meaning the quantity of experiments. The portrayal of T experiments follows. 
 
The primary line of each experiment contains two space-isolated whole numbers N and K. 
 
The subsequent line contains N space-isolated whole numbers W1,W2,… ,WN. 
 
Yield 
 
For each experiment, print a solitary line containing one whole number ― the most modest number of full circle trips or −1 in the event that it is unimaginable for Chef to bring all cases home. 
 
Requirements 
 
1≤T≤100 
 
1≤N,K≤103 
 
1≤Wi≤103 for each legitimate I 
 
Model Input 
 
 
 
 
2 4 
 
 
3 6 
 
3 4 2 
 
3 6 
 
3 4 3 
 
Model Output 
 
– 1 
 
 
 
 
Clarification 
 
Model case 1: Since the heaviness of the case higher than K, Chef can not convey that case home in quite a few the full circle. 
 
Model case 2: Since the aggregate of loads of both boxes is not as much as K, Chef can convey them home in one full circle. 
 
Model case 3: In the first full circle, Chef can just get the case at position 1. In the second full circle, he can get both remaining boxes at positions 2 and 3. 
 
Model case 4: Chef can just convey each crate in turn, so three trips there and back are required.
 

 

 

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment