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" . Farmer John hasNNcows , each capable of producing some amount of milk every day. TheMMstores near FJ's farm each offer to buy a certain amount of milk at a certain price. Moreover, Farmer John'sR 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.
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 NN cows (1≤N≤100,000), each capable of producing some amount of milk every day. The MM stores near FJ's farm (1≤M≤100,000) each offer to buy a certain amount of milk at a certain price. Moreover, Farmer John's R (1≤R≤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.
标签: HBC24252呼兰河传 质因数分解 gcd与exgcd 筛法 数论[USACO 2018 Jan S]Rental Service题解