QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 128 MB 満点: 100

#4739. 石头

統計

一块石头位于无限网格上的点 $(0, 0)$ 处。这块石头恰好有 $n$ 种可能的移动方式(不一定唯一),每种方式由一个整数坐标向量描述。石头每种移动方式最多只能使用一次,且移动的顺序可以任意安排。

目标是到达一个距离初始位置尽可能远(按欧几里得距离计算)的点。请问该距离是多少?

输入格式

标准输入的第一行包含一个正整数 $n$,表示可能的移动次数。接下来的 $n$ 行,每行包含两个整数 $x_i, y_i$ ($-10^4 \le x_i, y_i \le 10^4$),中间用空格分隔,形成向量 $[x_i, y_i]$,描述了石头的一种可能移动。

输出格式

你的程序应向标准输出打印一个整数,即石头能到达的最远点到 $(0, 0)$ 的距离的平方。

样例

样例输入 1

5
2 -2
-2 -2
0 2
3 1
-3 1

样例输出 1

26

说明

该图展示了一个最优解,使用了向量 $[0, 2]$、$[3, 1]$ 和 $[2, -2]$。另一个最优解由向量 $[0, 2]$、$[-3, 1]$ 和 $[-2, -2]$ 组成。

子任务

测试集由以下子任务组成。每个子任务内可能包含多个测试点。

子任务 属性 分值
1 $n \le 20$ 15
2 $n \le 2000$ 45
3 $n \le 200\,000$ 40

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.