Zerojudge j605. 程式考試

題解

照著題目做就好了,要注意如果分數小於0要回傳0

Python 解答

# 設定變數
submit = int(input())
highest_score = -1
first_highest_time = 0
error_time = 0

# 輸入數值與處理
for _ in range(submit):
    time, score = map(int, input().split())
    # 紀錄總嚴重錯誤次數會加一
    if score == -1:
        error_time += 1
    # 更新最高分
    if score > highest_score:
        highest_score = score
        first_highest_time = time

# 提交紀錄中的最高分 - 總提交次數 - 總嚴重錯誤次數 * 2
endScore = highest_score - submit - error_time*2

# 調整最後分數
if endScore < 0:
    endScore = 0

print(endScore, first_highest_time)