题目链接:

B. Coat of Anticubism

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

 
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 li.

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!

Input
 

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

The second line contains n integers li (1 ≤ li ≤ 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.

Output
 

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.

Examples
input
3
1 2 1
output
1
input
5
20 4 3 2 1
output
11
Note

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}.

题意

给出这些不能形成凸多边形的边,问至少加多长才能形成凸多边形;

思路

不能形成凸多边形说明最长的那条边太长,所以把除了最长边的其它边加在一起再加上答案使其比最长边大一就行;

AC代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+;
const int N=1e5+;
const int inf=0x3f3f3f3f;
const double PI=acos(-1.0);
int a[N];
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
sort(a+,a+n+);
LL sum=;
for(int i=;i<n;i++)
{
sum+=(LL)a[i];
}
cout<<a[n]-sum+<<"\n";
// printf("%I64d\n",a[n]-sum+1); return ;
}

codeforces 667B B. Coat of Anticubism(水题)的更多相关文章

  1. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  2. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  3. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  4. Codeforces Beta Round #37 A. Towers 水题

    A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...

  5. codeforces 677A A. Vanya and Fence(水题)

    题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  6. CodeForces 690C1 Brain Network (easy) (水题,判断树)

    题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...

  7. Codeforces - 1194B - Yet Another Crosses Problem - 水题

    https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...

  8. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  9. CodeForces 686A Free Ice Cream (水题模拟)

    题意:给定初始数量的冰激凌,然后n个操作,如果是“+”,那么数量就会增加,如果是“-”,如果现有的数量大于等于要减的数量,那么就减掉,如果小于, 那么孩子就会离家.问你最后剩下多少冰激凌,和出走的孩子 ...

随机推荐

  1. css,世界上没有绝对简单的事情

    引文 自从学了前端的基础,自认为是没什么css是能难倒我的,可是事实是,世界上没有绝对简单的事情,实际上还有好多的东西等待我们去发掘. 详解 1.有些浏览器不完全支持css3,现在可以用 modern ...

  2. Iass、Pass、SasS三种云服务区别?

    Iass.Pass.SasS三种云服务区别 我们可以把云计算理解成一栋大楼,而这栋楼又可以分为顶楼.中间.低层三大块.那么我们就可以把Iass(基础设施).Pass(平台).Sass(软件)理解成这栋 ...

  3. Spring Tool Suite (STS) 安装SVN插件

    今天STS安装SVN时遇到很多问题,度娘搜索几个小时才安装成功. 在此记录下安装过程. 我的 STS版本: 安装SVN有两种方式: 方法1:依次选择help->preferences->e ...

  4. 解决树莓派8G的SD卡只能识别3.3G,SD卡扩容

    8GB microSD在Windows下使用Win32 Disk Imager下载映像后,在RPi中只能识别出3.3GB.而本身还有很多容量没有释放出来. 使用sudo raspi-config工具可 ...

  5. Linux下运行Java项目时,出现No X11 DISPLAY variable was set, but this program performed an operation which requires it.的问题解决

    在~/.bashrc环境变量文件最下方加入: export DISPLAY=:0.0 然后,刷新环境变量以使其生效: source -/.bashrc 参考:http://stackoverflow. ...

  6. $.ajax里一个中文全角逗号引发的惨案

    昨天,在制作一个页面时,突然发生一件不可思议的事情--JS失效了! 确实让人匪夷所思,我记得饭前还是正常运作的. 于是慢慢的缩小范围,把下午刚加的语句删掉,删完了页面就正常了. 于是被删除的这部分代码 ...

  7. 系统重装 如何转换GPT的磁盘格式为MBR或者反过来

    使用分区助手专业版可以让磁盘在GPT和MBR之间进行转换   一般把磁盘全部格式化并清除分区,剩下的都会是可用空间,还是需要重建MBR来把磁盘转换成MBR格式的   转换会设置操作系统类型    

  8. BeagleBone Black Industrial 工业版介绍

    前言 在电子发烧友论坛看到有Beaglebone Black Industrial版的试用,这里介绍一下这块开发板. BBB是开源硬件,原理图.BOM等都开放下载,所以也有诸多兼容板. BBB兼容产品 ...

  9. HDU 4334 Trouble(哈希|线性查找)

    给定五个集合.问是否能从五个集合各取一个元素,使得元素之和为0. 这道题有两种做法,一种是哈希,然而之前没写过哈希.....比赛后从大神那copy了一份. 这里说还有一种. 对于这五个集合分为三组.1 ...

  10. Objective C运行时(runtime)技术总结,好强大的runtime

    前言:          Objective C的runtime技术功能非常强大,能够在运行时获取并修改类的各种信息,包括获取方法列表.属性列表.变量列表,修改方法.属性,增加方法,属性等等,本文对相 ...