Closest Cow Wins

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Farmer John owns a long farm along the highway that can be considered somewhat like a one-dimensional number line. Along the farm, there are KK grassy patches (1K21051 \leq K \leq 2\cdot 10^5); the ii-th patch is located at position p_ip\_i and has an associated tastiness value t_it\_i (0t_i1090\le t\_i\le 10^9). Farmer John's nemesis, Farmer Nhoj, has already situated his MM cows (1M21051 \leq M \leq 2\cdot 10^5) at locations f_1f_Mf\_1 \ldots f\_M. All K+MK+M of these locations are distinct integers in the range \[0,109]\[0,10^9].

Farmer John needs to pick NN (1N21051\le N\le 2\cdot 10^5) 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.

입력

The first line contains KK, MM, and NN.

The next KK lines each contain two space-separated integers p_ip\_i and t_it\_i.

The next MM lines each contain a single integer f_if\_i.

출력

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++).