| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 348435 | khoaipx | Pod starim krovovima (COCI20_psk) | Cpython 3 | 257 ms | 3308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import sys
def read_input(input_path=None):
if input_path is None:
f = sys.stdin
else:
f = open(input_path, 'r')
n = int(f.readline().rstrip())
cups = list()
for _ in range(n):
c, v = map(int, f.readline().split())
cups.append((c, v))
return n, cups
def sol(n, cups):
i_cups = list()
for i, cup in enumerate(cups):
i_cups.append([i, cup[0], cup[1]])
i_cups = sorted(i_cups, key=lambda x: x[2])
for i in range(n - 1):
c = i_cups[i][1]
j = i + 1
while c > 0 and j < n:
t = i_cups[j][1]
i_cups[j][1] = min(i_cups[j][2], i_cups[j][1] + c)
c = c - (i_cups[j][1] - t)
i_cups[i][1] = c
j += 1
i_cups = sorted(i_cups, key=lambda x: x[0])
num_empty = 0
for cup in i_cups:
if cup[1] == 0:
num_empty += 1
lines = list()
lines.append(f"{num_empty}")
lines.append(f"{' '.join(map(str, [cup[1] for cup in i_cups]))}")
return lines
def answer(input_path=None):
return sol(*read_input(input_path))
def main():
for line in sol(*read_input()):
print(f"{line}")
if __name__ == '__main__':
main()
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
