
USACO 2021 December Contest, Silver
Problem 1. Closest Cow Wins
Contest has ended.

Log in to allow submissions in analysis mode
Farmer John needs to pick N (1≤N≤2⋅105) locations (not necessarily integers) for his cows to be located. These must be distinct from those 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 of that patch. If there are two cows from rival farmers equally close to the patch, then Farmer Nhoj claims the patch.
Given the locations of Farmer Nhoj's cows and the locations and tastiness values of the grassy patches, determine the maximum total tastiness Farmer John's cows can claim if optimally positioned.
INPUT FORMAT (input arrives from the terminal / stdin):
The first line contains K, M, and N.The next K lines each contain two space-separated integers pi and ti.
The next M lines each contain a single integer fi.
OUTPUT FORMAT (print output to the terminal / stdout):
An integer denoting the maximum total tastiness. Note that the answer to this problem can be too large to fit into a 32-bit integer, so you probably want to use 64-bit integers (e.g., "long long"s in C or C++).SAMPLE INPUT:
6 5 2 0 4 4 6 8 10 10 8 12 12 13 14 2 3 5 7 11
SAMPLE OUTPUT:
36
If Farmer John places cows at positions 11.5 and 8 then he can claim a total tastiness of 10+12+14=36.
Problem credits: Brian Dean