문제
Deep in the countryside, Farmer John’s cows aren’t just ordinary farm animals—they are part of a clandestine bovine intelligence network. Each cow carries an ID number, carefully assigned by the elite cow cryptographers. However, due to Farmer John's rather haphazard tagging system, some cows ended up with the same ID.
Farmer John noted that there are () unique ID numbers, and for each unique ID (), there are () cows who shared it.
The cows can only communicate in pairs, and their secret encryption method has one strict rule: two cows can only exchange information if they are not the same cow and the sum of their ID numbers equals either or (). A cow can only engage in one conversation at a time (i.e., no cow can be part of more than one pair).
Farmer John would like to maximize the number of disjoint communication pairs to ensure the best information flow. Can you determine the largest number of conversations that can happen at once?
입력
The first line contains , , .
The next lines each contain and . No two are the same.
출력
The maximum number of disjoint communicating pairs that can be formed at the same time. Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).
예제 입력 1
4 4 5
17 2
100 0
10 1
200 4
예제 출력 1
118
예제 입력 2
4 4 5
100 0
10 1
100 3
20 4
예제 출력 2
30
점수
Inputs 3-4: Inputs 5-7: Inputs 8-12: No additional constraints
코드를 제출하려면 로그인이 필요합니다.
로그인