A10448 | Coat of Anticubism
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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!
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!
输入格式
The first line contains an integer $n$ ( $3<=n<=10^{5}$ ) — a number of rod-blanks.
The second line contains $n$ integers $l_{i}$ ( $1<=l_{i}<=10^{9}$ ) — 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.
The second line contains $n$ integers $l_{i}$ ( $1<=l_{i}<=10^{9}$ ) — 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.
输出格式
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.
输入输出样例
输入 #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}$ .
In the second example you can make a triangle with lengths ${20,11,4+3+2+1=10}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted