-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathninjacart_problem2.py
45 lines (38 loc) · 950 Bytes
/
ninjacart_problem2.py
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
'''
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
T = int(input())
for i in range(T):
score = 0
n = int(input())
tiles = []
for tile in range(n):
tiles.append(list(map(int,input().split())))
print(tiles[1])
i = n
while i > 0:
print(i-1)
a,b,c = tiles[i-1]
if i+3 < n:
score += c
i=i+3
elif i+2 < n:
score += b
i += 2
elif i+3 == n :
score += c
i += 3
elif i+2 == n :
score += b
i += 2
elif i == n:
score += c
i += 3
else :
score += a
i+=1
print(score)