-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathPython.py
35 lines (28 loc) · 934 Bytes
/
Python.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
#****************************************#
#* *#
#* CodinGame.com Solutions by pathosDev *#
#* *#
#* Puzzle: Temperatures *#
#* Difficulty: Easy *#
#* Date solved: 08.11.2018 *#
#* *#
#****************************************#
import sys
#Read inputs.
N = int(input())
inputs = input().split()
#If there are no temperatures provided, output 0.
if N <= 0:
print(0)
quit()
closestToZero = sys.maxsize
for i in range(N):
T = int(inputs[i])
#Find the closest to zero.
if abs(T) < abs(closestToZero):
closestToZero = T
#Find the positive number that is closest to zero instead of the negative number (see 5 and -5).
elif abs(T) == abs(closestToZero):
closestToZero = max(closestToZero, T)
#Print output.
print(closestToZero)