-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path381A.py
34 lines (28 loc) · 857 Bytes
/
381A.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
# @author Matheus Alves dos Santos
def is_even(value):
return ((value % 2) == 0)
n_cards = int(input())
cards = list(map(int, input().split()))
pointers = [0, n_cards - 1]
score = [0, 0]
player_flag = True
for i in range(n_cards):
if (is_even(n_cards) and (pointers[0] > pointers[1])):
break
if (player_flag):
player_flag = False
if (cards[pointers[0]] >= cards[pointers[1]]):
score[0] += cards[pointers[0]]
pointers[0] += 1
else:
score[0] += cards[pointers[1]]
pointers[1] -= 1
else:
player_flag = True
if (cards[pointers[0]] >= cards[pointers[1]]):
score[1] += cards[pointers[0]]
pointers[0] += 1
else:
score[1] += cards[pointers[1]]
pointers[1] -= 1
print(score[0], score[1])