Manly Kwak Cheol-yong
Time limit1sMemory limit256 MB
Given each player's two card numbers and Kwak Cheol-yong's pair, count how many players have a remainder-difference score under K higher than his.
- Level
Easy2 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Our idol Kwak Cheol-yong loves gambling with hwatu cards. This time he wants to try a new game with his friends.
The game is played by players using cards. The cards are numbered from 1 to , and no two cards share a number. First, each player takes 2 cards from the cards and discards them. Then each of the players draws 2 cards. The winner is decided by the numbers on the two cards drawn in the second round. A player's score is the difference between the remainders when the numbers on their two cards are divided by .
After both rounds of drawing, Kwak Cheol-yong wonders whether he can win the game. He wants to know the maximum number of players whose score is higher than his. Help ease his nerves.
Input
The first line contains positive integers , , and . (, )
From the second line through the -th line, each player's two positive integers and are given, which are the numbers on the cards drawn in the first round. ()
The -th line contains two positive integers and , which are the numbers on the cards Kwak Cheol-yong drew in the second round. ()
Output
Print the maximum number of players whose score is higher than Kwak Cheol-yong's score.