QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100 Hackable ✓

#16098. 无线网络发射器选址

الإحصائيات

随着智能手机的日益普及,人们对无线网的需求日益增大。某城市决定对城市内的公共场所覆盖无线网。

假设该城市的布局为由严格平行的 $129$ 条东西向街道和 $129$ 条南北向街道所形成的网格状,并且相邻的平行街道之间的距离都是恒定值 $1$。东西向街道从北到南依次编号为 $0,1,2 \dots 128$,南北向街道从西到东依次编号为 $0,1,2 \dots 128$。

东西向街道和南北向街道相交形成路口,规定编号为 $x$ 的南北向街道和编号为 $y$ 的东西向街道形成的路口的坐标是 $(x, y)$。在某些路口存在一定数量的公共场所。

由于政府财政问题,只能安装一个大型无线网络发射器。该无线网络发射器的传播范围是一个以该点为中心,边长为 $2d$ 的正方形。传播范围包括正方形边界。

例如下图是一个 $d = 1$ 的无线网络发射器的覆盖范围示意图。

problem_16098_1.png

现在政府有关部门准备安装一个传播参数为 $d$ 的无线网络发射器,希望你帮助他们在城市内找出合适的路口作为安装地点,使得覆盖的公共场所最多。

输入格式

第一行包含一个整数 $d$,表示无线网络发射器的传播距离。

第二行包含一个整数 $n$,表示有公共场所的路口数目。

接下来 $n$ 行,每行给出三个整数 $x, y, k$,中间用一个空格隔开,分别代表路口的坐标 $(x, y)$ 以及该路口公共场所的数量。同一坐标只会给出一次。

输出格式

输出一行,包含两个整数,用一个空格隔开,分别表示能覆盖最多公共场所的安装地点方案数,以及能覆盖的最多公共场所的数量。

样例一

input

1
2
4 4 10
6 6 20

output

1 30

限制与约定

对于 $100\%$ 的数据,$1 \leq d \leq 20, 1 \leq n \leq 20, 0 \leq x \leq 128, 0 \leq y \leq 128, 0 < k \leq 1\,000\,000$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.