CF1221F.Choose a Square

提高+/省选-

通过率:0%

时间限制:6.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya recently found a game "Choose a Square". In this game, there are nn points numbered from 11 to nn on an infinite field. The ii-th point has coordinates (xi,yi)(x_i, y_i) and cost cic_i.

You have to choose a square such that its sides are parallel to coordinate axes, the lower left and upper right corners belong to the line y=xy = x, and all corners have integer coordinates.

The score you get is the sum of costs of the points covered by the selected square minus the length of the side of the square. Note that the length of the side can be zero.

Petya asks you to calculate the maximum possible score in the game that can be achieved by placing exactly one square.

佩佳最近发现了一个名为“选择正方形”的游戏。在这个游戏中,一个无限大的平面上有 nn 个编号为 11 到 nn 的点。第 ii 个点的坐标为 (xi,yi)(x_i, y_i),代价为 cic_i。

你需要选择一个正方形,满足以下条件:其边与坐标轴平行;其左下角和右上角均位于直线 y=xy = x 上;且所有顶点的坐标均为整数。

你获得的分数等于该正方形所覆盖的所有点的代价之和,减去该正方形边长。注意:边长可以为零。

佩佳请你计算:通过恰好放置一个正方形,所能获得的最大可能分数。

输入格式

The first line of the input contains one integer nn (1≤n≤5⋅1051 \le n \le 5 \cdot 10^5) — the number of points on the field.

Each of the following nn lines contains three integers xi,yi,cix_i, y_i, c_i (0≤xi,yi≤109,−106≤ci≤1060 \le x_i, y_i \le 10^9, -10^6 \le c_i \le 10^6) — coordinates of the ii-th point and its cost, respectively.

输入的第一行包含一个整数 nn(1≤n≤5⋅1051 \le n \le 5 \cdot 10^5)—— 表示场上的点的数量。

接下来的 nn 行中,每行包含三个整数 xi,yi,cix_i, y_i, c_i(0≤xi,yi≤1090 \le x_i, y_i \le 10^9,−106≤ci≤106-10^6 \le c_i \le 10^6)—— 分别表示第 ii 个点的坐标及其代价。

输出格式

In the first line print the maximum score Petya can achieve.

In the second line print four integers x1,y1,x2,y2x_1, y_1, x_2, y_2 (0≤x1,y1,x2,y2≤2⋅109,x1=y1,x2=y2,x1≤x20 \le x_1, y_1, x_2, y_2 \le 2 \cdot 10^9, x_1 = y_1, x_2 = y_2, x_1 \le x_2) separated by spaces — the coordinates of the lower left and upper right corners of the square which Petya has to select in order to achieve the maximum score.

第一行输出佩蒂亚能够获得的最高得分。

第二行输出四个整数 x1,y1,x2,y2x_1, y_1, x_2, y_2(0≤x1,y1,x2,y2≤2⋅1090 \le x_1, y_1, x_2, y_2 \le 2 \cdot 10^9,且满足 x1=y1x_1 = y_1,x2=y2x_2 = y_2,x1≤x2x_1 \le x_2),以空格分隔——表示佩蒂亚为获得最高得分所需选取的正方形的左下角与右上角坐标。

输入输出样例

  • 输入#1

    6
    0 0 2
    1 0 -5
    1 1 3
    2 3 4
    1 4 -4
    3 1 -1

    输出#1

    4
    1 1 3 3
  • 输入#2

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

    输出#2

    0
    1 1 1 1

说明/提示

The field corresponding to the first example:

对应第一个示例的场:

输入解题思路,AI测评打分。不知道怎么写?

首页