QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 1024 MB 總分: 100

#2166. 机会成本

统计

购买新手机往往是一件困难的事情。主要挑战之一是你可能关心手机的许多不同方面,例如价格、性能以及手机的易用性。通常情况下,没有哪一款手机能同时在所有这些方面都做到最好:最便宜的手机、性能最强的手机和最易用的手机往往是不同的。

因此,在购买手机时,你被迫在关心的不同方面之间进行权衡,做出一些牺牲,并选择一款达到最佳折中方案的手机(当然,“最佳”取决于你的优先考虑事项)。衡量这种牺牲的一种方法被称为机会成本,我们将其定义如下:

假设你购买了一款价格为 $x$、性能为 $y$、易用性为 $z$ 的手机。为简单起见,我们假设这三个值是在一个可比较的数值尺度上衡量的,数值越高越好。如果有 $n$ 款可选手机,且 $(x_i, y_i, z_i)$ 代表第 $i$ 款手机的(价格、性能、易用性),那么你所选手机的机会成本定义为:

$$\max_{1 \le i \le n} (\max(x_i - x, 0) + \max(y_i - y, 0) + \max(z_i - z, 0))$$

编写一个程序,给定可选手机列表,找到机会成本最小的手机。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 200\,000$),表示考虑的手机数量。 接下来有 $n$ 行。其中第 $i$ 行包含三个整数 $x_i, y_i, z_i$,分别表示第 $i$ 款手机的价格、性能和易用性 ($1 \le x_i, y_i, z_i \le 10^9$)。

输出格式

输出一行,包含两个整数:最小可能的机会成本,以及一个 $1$ 到 $n$ 之间的整数,表示达到该机会成本的手机编号。如果存在多款手机达到该机会成本,输出编号最小的那一款。

样例

样例输入 1

4
20 5 5
5 20 5
5 5 20
10 10 10

样例输出 1

10 4

样例输入 2

4
15 15 5
5 15 15
15 5 15
10 10 10

样例输出 2

10 1

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.