CF667B.Coat of Anticubism

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.

A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-dimensional objects through three-dimensional objects by using his magnificent sculptures. And his new project is connected with this. Cicasso wants to make a coat for the haters of anticubism. To do this, he wants to create a sculpture depicting a well-known geometric primitive — convex polygon.

Cicasso prepared for this a few blanks, which are rods with integer lengths, and now he wants to bring them together. The i-th rod is a segment of length l__i.

The sculptor plans to make a convex polygon with a nonzero area, using all rods he has as its sides. Each rod should be used as a side to its full length. It is forbidden to cut, break or bend rods. However, two sides may form a straight angle .

Cicasso knows that it is impossible to make a convex polygon with a nonzero area out of the rods with the lengths which he had chosen. Cicasso does not want to leave the unused rods, so the sculptor decides to make another rod-blank with an integer length so that his problem is solvable. Of course, he wants to make it as short as possible, because the materials are expensive, and it is improper deed to spend money for nothing.

Help sculptor!

众所周知,立体主义(Cubism)是艺术领域的一种流派,其核心问题在于:如何在平面上通过组合三维几何体来构建具有体积感的形状。

著名雕塑家西卡索(Cicasso)——你眼前所见正是他的自画像——十分反感立体主义。他更倾心于另一种理念:借助自己精湛的雕塑技艺,将二维对象以三维形式呈现出来。而他的新项目正与这一理念密切相关。西卡索打算为“反立体主义憎恨者”制作一件外套。为此,他计划创作一座雕塑,用以表现一种广为人知的几何基本形——凸多边形。

西卡索已为此准备了一批坯料,即若干根长度为整数的杆状材料,现需将它们组合起来。第 ii 根杆的长度为 lil_i。

雕塑家计划使用所有现有杆材作为边,构造一个面积不为零的凸多边形。每根杆必须以其全长作为一条边使用;严禁切割、折断或弯曲任何杆材。但允许两条邻边构成平角(即 180∘180^\circ 角)!。

西卡索意识到,仅凭他目前已选定的这些杆材长度,无法构造出面积不为零的凸多边形。他又不愿留下任何未使用的杆材,因此决定额外制作一根长度为整数的新杆材,使得问题变得可解。当然,他希望这根新增杆材尽可能短,因为原材料价格昂贵,毫无必要地浪费金钱是极不妥当的行为。

请帮助这位雕塑家!

输入格式

The first line contains an integer n (3 ≤ n ≤ 105) — a number of rod-blanks.

The second line contains n integers l__i (1 ≤ l__i ≤ 109) — lengths of rods, which Cicasso already has. It is guaranteed that it is impossible to make a polygon with n vertices and nonzero area using the rods Cicasso already has.

第一行包含一个整数 nn(3≤n≤1053 \leq n \leq 10^5)—— 表示杆坯的数量。

第二行包含 nn 个整数 lil_i(1≤li≤1091 \leq l_i \leq 10^9)—— 表示 Cicasso 已有的杆的长度。题目保证:使用 Cicasso 当前拥有的这些杆,无法构成一个具有 nn 个顶点且面积非零的多边形。

输出格式

Print the only integer z — the minimum length of the rod, so that after adding it it can be possible to construct convex polygon with (n + 1) vertices and nonzero area from all of the rods.

输出唯一的整数 zz —— 即所需添加的杆的最小长度,使得在加入该杆后,能够用所有这些杆(共 n+1n+1 根)构成一个具有非零面积的凸多边形。

输入输出样例

  • 输入#1

    3
    1 2 1

    输出#1

    1
  • 输入#2

    5
    20 4 3 2 1

    输出#2

    11

说明/提示

In the first example triangle with sides {1 + 1 = 2, 2, 1} can be formed from a set of lengths {1, 1, 1, 2}.

In the second example you can make a triangle with lengths {20, 11, 4 + 3 + 2 + 1 = 10}.

在第一个例子中,可以从长度集合 {1, 1, 1, 2}\{1,\,1,\,1,\,2\} 构造出边长为 {1+1=2, 2, 1}\{1+1=2,\,2,\,1\} 的三角形。

在第二个例子中,可以构造出边长为 {20, 11, 4+3+2+1=10}\{20,\,11,\,4+3+2+1=10\} 的三角形。

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

首页