Codingame : Temperature

Root(√)·2020년 8월 6일
0

https://www.codingame.com/training/easy/temperatures

import sys
import math
# 내장함수 최대한 쓰지 않는 방향의 코드로.. 
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())  # the number of temperatures to analyse
t_list = []
t_list_absolute = []
for i in input().split():
    # t: a temperature expressed as an integer ranging from -273 to 5526
    t = int(i)
    t_list.append(t)
    if t < 0 :
        t = t * -1
        t_list_absolute.append(t)
    else:
        t_list_absolute.append(t)

if not t_list_absolute == []: # temperature가 존재한다면
    result = t_list_absolute[0]

    for i in t_list_absolute:
        if i < result:
            result = i 

    if result not in t_list: #result가 음수라는 이야기
        result = result * -1
else:
    result = 0


# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)

print(result)
profile
Software Engineer

0개의 댓글