Optimal Milking
의견: 0
Farmer John has recently purchased a new barn containing N milking machines (1 <= N <= 40,000), conveniently numbered 1..N and arranged in a row.
Milking machine i is capable of extracting M(i) units of milk per day (1 <= M(i) <= 100,000). Unfortunately, the machines were installed so close together that if a machine i is in use on a particular day, its two neighboring machines cannot be used that day (endpoint machines have only one neighbor). Farmer John is free to select different subsets of machines to operate on different days.
Farmer John is interested in computing the maximum amount of milk he can extract over a series of D days (1 <= D <= 50,000). At the beginning of each day, he has enough time to perform maintenance on one selected milking machine i, thereby changing its daily milk output M(i) from that day forward. Given a list of these daily modifications, please tell Farmer John how much milk he can produce over D days (this number might not fit into a 32-bit integer).
Line 1: The values of N and D.
Lines 2..1+N: Line i+1 contains the initial value of M(i).
Lines 2+N..1+N+D: Line 1+N+d contains two integers i and m, indicating that Farmer John updates the value of M(i) to m at the beginning of day d.
The maximum total amount of milk FJ can produce over D days.
optmilk.inoptmilk.out5 3
1
2
3
4
5
5 2
2 7
1 1032Output details: Day 1 optimum is 6, day 2 is 11, day 3 is 15, total 32.
riseoj 작성
출처 올림피아드 > USACO > 2013-2014 > December > Gold
평가 및 의견
Optimal Milking
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Optimal Milking