File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
codechef/warmup_and_complexity Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Problem statement: https://www.codechef.com/LRNDSA01/problems/CARVANS
3+ """
4+
5+ def calculate (n , max_speeds ):
6+ max_speed_count = 0
7+ lowest_so_far = - 1
8+ for speed in max_speeds :
9+ if lowest_so_far == - 1 :
10+ lowest_so_far = speed
11+ max_speed_count += 1
12+ continue
13+ if speed <= lowest_so_far : # cars having speed eqauls to or lesser than the lowest speed so far, are moving at their max speed.
14+ lowest_so_far = speed
15+ max_speed_count += 1
16+ return max_speed_count
17+
18+
19+ if __name__ == '__main__' :
20+ T = int (input ()) # input number of test cases.
21+
22+ for i in range (T ):
23+ N = int (input ()) # enter number of cars
24+ max_car_speeds = list (map (int , input ().split ()))
25+ res = calculate (N , max_car_speeds )
26+ print (res )
27+
28+
29+
You can’t perform that action at this time.
0 commit comments