#USACOC2213A. Closest Cow Wins
Closest Cow Wins
Description
Farmer John owns a long farm along the highway that can be considered somewhatlike a one-dimensional number line. Along the farm, there are grassy patches; the -th patch is located at position and has an associated tastiness value . Farmer John's nemesis, Farmer Nhoj, has already situated his cows at locations . All of theselocations are distinct integers in the range .
Farmer John needs to pick locations (notnecessarily integers) for his cows to be located. These must be distinct fromthose already occupied by the cows of Farmer Nhoj, but it is possible for Farmer John to place his cows at the same locations as grassy patches.
Whichever farmer owns a cow closest to a grassy patch can claim ownership ofthat patch. If there are two cows from rival farmers equally close to thepatch, then Farmer Nhoj claims the patch.
Given the locations of Farmer Nhoj's cows and the locations and tastiness valuesof the grassy patches, determine the maximum total tastiness Farmer John's cowscan claim if optimally positioned.
Input Format
The first line contains , , and .
The next lines each contain two space-separated integers and .
The next lines each contain a single integer .
Output Format
An integer denoting the maximum total tastiness. Note that the answer to thisproblem can be too large to fit into a 32-bit integer, so you probably want touse 64-bit integers (e.g., long long
s in C or C++).
6 5 2
0 4
4 6
8 10
10 8
12 12
13 14
2
3
5
7
11
36
If Farmer John places cows at positions and then he can claim a total tastiness of .
Problem Credit
Problem credits: Brian Dean