Official
B - 畑の収穫 / Harvest from the Field Editorial
by
B - 畑の収穫 / Harvest from the Field Editorial
by
harurun4635
一日で \(M\) の作業量が増加するため \(\displaystyle T = \left\lceil \frac{\sum D_i}{M} \right\rceil\) は必要です。逆に、これを満たす時、達成可能です。
証明は、前から \((1, 1), \dots , (1, D_1), (2, 1), \dots \dots, (N, D_N)\) と仕事を並べ、各人が前から仕事をとり、その畑に行くことにすれば良いです。
実装例
n, m = map(int, input().split())
d = list(map(int, input().split()))
print((sum(d) + m - 1) // m)
posted:
last update: