GitHub

https://github.com/Choidongjun0830

파이썬 알고리즘 문제 풀이

[HackerRank] Grading Students 파이썬

gogi masidda 2024. 2. 3. 15:24

https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true

 

Grading Students | HackerRank

Round student grades according to Sam's rules.

www.hackerrank.com

 

def gradingStudents(N, grades):
    # Write your code here
    result = grades
    for i in range(len(grades)):
        for j in range(3):
            temp = grades[i] + j
            if grades[i] > 37 and temp % 5 == 0:
                result[i] = temp
    return result

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    grades_count = int(input().strip())

    grades = []

    for _ in range(grades_count):
        grades_item = int(input().strip())
        grades.append(grades_item)

    result = gradingStudents(grades_count, grades)

    fptr.write('\n'.join(map(str, result)))
    fptr.write('\n')

    fptr.close()

 

if grades[i] > 37을 통해 40보다 작으면서 반올림이 불가한 것을 제외시켰다.

728x90