#P2345. [USACO04OPEN] MooFest G
[USACO04OPEN] MooFest G
Description
John’s cows attend “MooFest” every year.
MooFest is a grand event in the cow world. There are many activities at the gathering, such as stacking hay, jumping over fences, and patting cowboys on the butt.
When they participate in activities, they gather together. The -th cow is located at coordinate , and no two cows share the same coordinate.
The cows are very loud. When the -th and -th cows communicate, they produce a volume of , where and are the hearing abilities of cows and , respectively.
Assume that every pair of cows is talking at the same time. Please compute the sum of the volume produced by all cows.
Input Format
- The first line: a single integer , .
- Lines to : the -th line contains two integers and ().
Output Format
A single integer: the total volume produced by all cows.
4
3 1
2 5
2 6
4 3
57
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号