#P2038. [NOIP 2014 提高组] 无线网络发射器选址
[NOIP 2014 提高组] 无线网络发射器选址
Description
With the increasing popularity of smartphones, the demand for wireless networks is growing. A certain city decides to cover public places with a wireless network.
Assume the city layout is a grid formed by east-west streets and north-south streets, and the distance between any two adjacent parallel streets is a constant . The east-west streets are numbered from north to south, and the north-south streets are numbered from west to east.
Intersections are formed where an east-west street meets a north-south street. The intersection of the north-south street numbered and the east-west street numbered has coordinates . Some intersections have a certain number of public places.
Due to budget constraints, only one large wireless network transmitter can be installed. Its coverage area is a square centered at the installation point with side length . The coverage includes the square’s boundary.
Now the authorities plan to install a transmitter with parameter . Please help them find a suitable intersection in the city as the installation location to maximize the number of public places covered.
Input Format
The first line contains an integer , the coverage parameter of the wireless network transmitter.
The second line contains an integer , the number of intersections that have public places.
The next lines each contain three integers separated by a space, representing the intersection coordinates and the number of public places at that intersection. Each coordinate appears at most once.
Output Format
Output one line containing two integers separated by a space: the number of installation locations that achieve the maximum coverage of public places, and the maximum number of public places covered.
1
2
4 4 10
6 6 20
1 30
Hint
For of the testdata, $1 \leq d \leq 20, 1 \leq n \leq 20, 0 \leq x \leq 128, 0 \leq y \leq 128, 0 < k \leq 10^6$.
Translated by ChatGPT 5
京公网安备 11011102002149号