RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0307 파일 입출력

Rental Service

Gold I 골드 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John realizes that the income he receives from milk production is
insufficient to fund the growth of his farm, so to earn some extra money, he
launches a cow-rental service, which he calls "USACOW" (pronounced "Use-a-cow").

Farmer John has \(N\) cows (\(1 \leq N \leq 100,000\)), each capable of producing
some amount of milk every day. The \(M\) stores near FJ's farm
(\(1 \leq M \leq 100,000\)) each offer to buy a certain amount of milk at a
certain price. Moreover, Farmer John's \(R\) (\(1 \leq R \leq 100,000\))
neighboring farmers are each interested in renting a cow at a certain price.

Farmer John has to choose whether each cow should be milked or rented to a
nearby farmer. Help him find the maximum amount of money he can make per day.

Problem credits: Jay Leeds

제약

Problem credits: Jay Leeds

입력 형식

The first line in the input contains \(N\), \(M\), and \(R\). The next \(N\) lines each
contain an integer \(c_i\) (\(1 \leq c_i \leq 1,000,000\)), indicating that Farmer
John's \(i\)th cow can produce \(c_i\) gallons of milk every day. The next \(M\) lines
each contain two integers \(q_i\) and \(p_i\) (\(1 \leq q_i, p_i \leq 1,000,000\)),
indicating that the \(i\)th store is willing to buy up to \(q_i\) gallons of milk
for \(p_i\) cents per gallon. Keep in mind that Farmer John can sell any amount
of milk between zero and \(q_i\) gallons to a given store. The next \(R\) lines each
contain an integer \(r_i\) (\(1 \leq r_i \leq 1,000,000\)), indicating that one of
Farmer John's neighbors wants to rent a cow for \(r_i\) cents per day.

출력 형식

The output should consist of one line containing the maximum profit Farmer John
can make per day by milking or renting out each of his cows. Note that the
output might be too large to fit into a standard 32-bit integer, so you may need
to use a larger integer type like a "long long" in C/C++.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 rental.in
출력을 쓸 파일 rental.out
예제 1
입력
5 3 4
6
2
4
7
1
10 25
2 10
15 15
250
80
100
40
출력
725
설명

Farmer John should milk cows #1 and #4, to produce 13 gallons of milk. He
should completely fill the order for 10 gallons, earning 250 cents, and sell the
remaining three gallons at 15 cents each, for a total of 295 cents of milk
profits.

Then, he should rent out the other three cows for 250, 80, and 100 cents, to
earn 430 more cents. (He should leave the request for a 40-cent rental
unfilled.) This is a total of 725 cents of daily profit.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2017-2018 > January > Silver

태그

평가 및 의견

Rental Service

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Rental Service

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8