PRATA - Roti Prata
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.
Input
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.
Output
Print an integer which tells the number of minutes needed to get the order done.
Example
Input:
3
10
4 1 2 3 4
8
1 1
8
8 1 1 1 1 1 1 1 1
Output:
12
36
1
hide comments
koustubh38:
2021-06-13 07:51:42
was it easy as i have solved two problems on same concept or i have learn to sole these problems |
|
coder_758:
2021-06-09 10:13:55
Ac in one go confidence level aasman farte hue |
|
garvit_99:
2021-05-22 09:35:42
good question mja aagya krke
|
|
sakshamtomar29:
2021-05-11 15:25:55
great Binary search question ! |
|
gearman_0712:
2021-05-03 08:52:53
No need to use fast i/o. c++. |
|
shubham_2974:
2021-04-24 14:38:27
AC in 2nd Go TC: L*log(P) using Binary Search
|
|
nav_8178:
2021-03-19 09:49:41
Can anyone uderstand me case 8 1 1 and should be 10 because 1 -
|
|
arafat_123:
2021-03-18 19:36:34
AC in one go!! Very good question of binary search.
|
|
arunjain9988:
2021-03-08 11:02:30
solved in p*log(m)*log(1e7) |
|
sparsh_2301:
2021-02-11 19:08:03
Is the time complexity O(L*Log(p))?? Last edit: 2021-02-11 19:08:22 |
Added by: | Saransh Bansal |
Date: | 2011-05-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own problem- NTU IEEE codejam 2011 |