-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchefanddeliver.py
More file actions
61 lines (51 loc) · 1.65 KB
/
chefanddeliver.py
File metadata and controls
61 lines (51 loc) · 1.65 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
test_case_count = raw_input()
for i in range(int(test_case_count)):
first_line = [int(x) for x in raw_input().split()]
# vehicle_count = first_line[0]
max_petrol = first_line[1]
initial_petrol_cap_per_vehicle = []
pakka = []
i = 1
for x in raw_input().split():
int1 = int(x)
if int1 >= i:
pakka.append(i)
else:
initial_petrol_cap_per_vehicle.append(i-int1)
i += 1
load_cap_per_vehicle = []
i = 1
_pakka_load = 0
for x in raw_input().split():
int2 = int(x)
if i not in pakka:
load_cap_per_vehicle.append(int2)
else:
_pakka_load += int2
i += 1
def consume_petrol(index_p, petrol_left_p):
if petrol_left_p <= 0:
return 0
_petrol_required = initial_petrol_cap_per_vehicle[index_p]
_load = load_cap_per_vehicle[index_p]
if index_p + 1 < initial_petrol_cap_per_vehicle.__len__():
load1 = consume_petrol(index_p + 1, petrol_left_p)
if _petrol_required <= petrol_left_p:
load2 = consume_petrol(index_p + 1, petrol_left_p - _petrol_required)
load2 += _load
if load1 > load2:
return load1
else:
return load2
return load1
if _petrol_required <= petrol_left_p:
return _load
else:
return 0
def consume_petrol_iter():
pass
if initial_petrol_cap_per_vehicle.__len__():
load_sum = consume_petrol(0, max_petrol)
print load_sum + _pakka_load
else:
print _pakka_load