PRATA - Roti Prata

no tags 

IEEE is having its AGM next week and the president wants to serve cheese prata after the meeting. The subcommittee members are asked to go to food connection and get P(P<=1000) pratas packed for the function. The stall has L cooks(L<=50) and each cook has a rank R(1<=R<=8). A cook with a rank R can cook 1 prata in the first R minutes 1 more prata in the next 2R minutes, 1 more prata in 3R minutes and so on(he can only cook a complete prata) ( For example if a cook is ranked 2.. he will cook one prata in 2 minutes one more prata in the next 4 mins an one more in the next 6 minutes hence in total 12 minutes he cooks 3 pratas in 13 minutes also he can cook only 3 pratas as he does not have enough time for the 4th prata). The webmaster wants to know the minimum time to get the order done. Please write a program to help him out.



The first line tells the number of test cases. Each test case consist of 2 lines. In the first line of the test case we have P the number of prata ordered. In the next line the first integer denotes the number of cooks L and L integers follow in the same line each denoting the rank of a cook.


Print an integer which tells the number of minutes needed to get the order done.




4 1 2 3 4
1 1
8 1 1 1 1 1 1 1 1

hide comments
nadstratosfer: 2018-03-16 18:20:48

shadow10, the cooks' finishing time for each prata:
1 - 1, 3, 6, 10
2 - 2, 6, 12
3 - 3, 9
4 - 4, 12
--> 10th (and 11th) prata served at minute 12.

Another problem that could be fun to play with but is ruined by idiotic time limit. Get formula to use in BS to get AC and don't waste time inventing your own algo because you won't get to see how it performs anyway. Why build a comprehensive testfile if one can set TL so low that a Py3 program doing nothing can't pass?

Last edit: 2018-03-16 21:35:32
pallindromeguy: 2018-03-16 09:50:15

Take upper limit to be 10000007 ;)

praney_rai: 2017-06-16 11:58:30

Binary Search Zinda Bad :P (Got WA using cin , cout but AC with fast i/o without changing even single line )WTF..

shadow10: 2017-03-16 16:25:13

I can't understand the first test case.I guess time should be greater than 12 min or i am mistaking somewhere.

vengatesh15: 2017-01-28 09:10:20

AC in 1 go did using priority_queue

anku2424: 2016-11-21 10:32:16

took me 2 days to figure out the idea! ac :) 0.00

Piyush Kumar: 2016-07-18 19:04:10

Bounds on number of test cases is not mentioned in the description.

.::Austin::.: 2016-07-14 21:50:01

Binary Search accepted in 0.0, :D

narutorocks: 2016-06-02 20:35:14


Last edit: 2016-06-02 20:56:52
bholagabbar: 2015-09-17 22:28:23

0.03 with priority queues. BS it times out

Added by:Saransh Bansal
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem- NTU IEEE codejam 2011