답안 #197948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197948 2020-01-24T11:57:38 Z model_code Pod starim krovovima (COCI20_psk) Python 3
44 / 50
456 ms 4668 KB
N = int(input())
 
stol = []
for i in range(N):
    Ti, Zi = map(int, input().split())
    stol += [[i, Ti, Zi]]
#print(stol)
 
stol = sorted(stol, key = lambda x: x[2])
 
#print(stol)
 
for i in range(N-1):
    koliko = stol[i][1]
    j = i + 1
    while koliko > 0 and j < N:
        t = stol[j][1]
        stol[j][1] = min(stol[j][2], stol[j][1] + koliko)
        koliko = koliko - (stol[j][1] - t)
        stol[i][1] = koliko
        j += 1
 
    #print(stol)
 
stol = sorted(stol, key = lambda x: x[0])
#print(stol)
 
ukupno = 0
for i in range(N):
    if stol[i][1] == 0:
        ukupno += 1
print(ukupno)

import random
random.shuffle(stol)
 
for i in range(N):
    print(stol[i][1], end = ' ')
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 4312 KB Output is correct
2 Correct 42 ms 4304 KB Output is correct
3 Correct 38 ms 4308 KB Output is correct
4 Correct 43 ms 4304 KB Output is correct
5 Partially correct 38 ms 4280 KB Output is partially correct
6 Partially correct 40 ms 4268 KB Output is partially correct
7 Partially correct 41 ms 4280 KB Output is partially correct
8 Partially correct 456 ms 4668 KB Output is partially correct
9 Partially correct 155 ms 4624 KB Output is partially correct
10 Partially correct 252 ms 4616 KB Output is partially correct