-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeLogic.txt
29 lines (21 loc) · 966 Bytes
/
theLogic.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
how did I solve this problem(linear search):
1 => takes the placesCount(N) and the timesCount(M)
from the first line
2 => calculate the sum(totalCookies) of the biscuits
line by line and at the same time save
the value of each line in a list
3 => call the function solve()
4 => In fn solve first sort the list
5 => defined the placesList, delete all the 0
6 => check if placesCount(N) without 0 more than timesCount(M)
return 0, that means that he can not visit all the places
because in one place he takes an hour. or if totalCookies 0
that means there are no biscuits in the office so we
return also 0
7 => if placesCount(N) without 0 the same us timesCount(m) return
the max Cn because he will visit every place just one time
8 => calculate the min num of K(k = sum / m), and
the max (k = cnMax)
9 => Call the fun isHighEnough() and check how much time he takes
for one place then subtract it from m, then return m >=0,tell min==max,
and return k