CF559E.Gerald and Path
NOI/NOI+/CTSC
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The main walking trail in Geraldion is absolutely straight, and it passes strictly from the north to the south, it is so long that no one has ever reached its ends in either of the two directions. The Geraldionians love to walk on this path at any time, so the mayor of the city asked the Herald to illuminate this path with a few spotlights. The spotlights have already been delivered to certain places and Gerald will not be able to move them. Each spotlight illuminates a specific segment of the path of the given length, one end of the segment is the location of the spotlight, and it can be directed so that it covers the segment to the south or to the north of spotlight.
The trail contains a monument to the mayor of the island, and although you can walk in either directions from the monument, no spotlight is south of the monument.
You are given the positions of the spotlights and their power. Help Gerald direct all the spotlights so that the total length of the illuminated part of the path is as much as possible.
杰拉尔迪恩市的主步行道完全笔直,严格地从北向南延伸,其长度如此之长,以至于从未有人到达过道路在任一方向上的尽头。杰拉尔迪恩市民喜欢随时在这条路上散步,因此该市市长委托 herald(传令官)用若干聚光灯来照亮这条道路。聚光灯已运抵若干指定位置,且杰拉尔德无法移动它们。每盏聚光灯可照亮道路上一段给定长度的区间:该区间的某一端点即为聚光灯所在位置,且聚光灯可朝南或朝北照射,从而覆盖其所在位置以南或以北的该段区间。
这条步行道上设有一座纪念该岛市长的纪念碑;尽管你可以从纪念碑出发向任意方向行走,但没有任何一盏聚光灯位于纪念碑以南。
你将获得所有聚光灯的位置及其照明能力(即能照亮的区间长度)。请帮助杰拉尔德为所有聚光灯确定照射方向,使得路径上被照亮的总长度尽可能大。
输入格式
The first line contains integer n (1 ≤ n ≤ 100) — the number of spotlights. Each of the n lines contains two space-separated integers, a__i and l__i (0 ≤ a__i ≤ 108, 1 ≤ l__i ≤ 108). Number a__i shows how much further the i-th spotlight to the north, and number l__i shows the length of the segment it illuminates.
It is guaranteed that all the a__i's are distinct.
第一行包含一个整数 n(1≤n≤100)—— 聚光灯的数量。接下来的 n 行中,每行包含两个用空格分隔的整数 ai 和 li(0≤ai≤108,1≤li≤108)。数值 ai 表示第 i 个聚光灯向北偏移的距离,数值 li 表示该聚光灯所照亮线段的长度。
保证所有的 ai 互不相同。
输出格式
Print a single integer — the maximum total length of the illuminated part of the path.
输出一个整数——路径被照亮部分的总长度的最大值。
输入输出样例
输入#1
3 1 1 2 2 3 3
输出#1
5
输入#2
4 1 2 3 3 4 3 6 2
输出#2
9
输入解题思路,AI测评打分。不知道怎么写?