https://www.hackerrank.com/challenges/breaking-best-and-worst-records/problem
HackerRank - Breaking the Records
#!/bin/python3import mathimport osimport randomimport reimport sysdef breakingRecords(scores): countBestScore = 0 countWorstScore = 0 bestScore = scores[0] worstScore = scores[0] for score in scores: if(bestScore < score): countBestScore += 1 bestScore = score elif(worstScore > score): countWorstScore += 1 worstScore = score return countBestScore, countWorstScoreif __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') n = int(input()) scores = list(map(int, input().rstrip().split())) result = breakingRecords(scores) fptr.write(' '.join(map(str, result))) fptr.write('\n') fptr.close()
'알고리즘 문제 풀기 > HackerRank' 카테고리의 다른 글
| HackerRank - Divisible Sum Pairs (0) | 2019.01.23 |
|---|---|
| HackerRank - Birthday Chocolate (0) | 2019.01.22 |
| HackerRank - Between Two Sets (0) | 2019.01.20 |
| HackerRank - Kangaroo (0) | 2019.01.19 |
| HackerRank - Apple and Orange (0) | 2019.01.18 |