日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

codeforces 667B B. Coat of Anticubism(水题)

發布時間:2025/6/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeforces 667B B. Coat of Anticubism(水题) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:

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+7; const int N=1e5+6; const int inf=0x3f3f3f3f; const double PI=acos(-1.0); int a[N]; int main() {int n;scanf("%d",&n);for(int i=1;i<=n;i++){scanf("%d",&a[i]);}sort(a+1,a+n+1);LL sum=0;for(int i=1;i<n;i++){sum+=(LL)a[i];}cout<<a[n]-sum+1<<"\n";// printf("%I64d\n",a[n]-sum+1);return 0; }

?

轉載于:https://www.cnblogs.com/zhangchengc919/p/5451482.html

總結

以上是生活随笔為你收集整理的codeforces 667B B. Coat of Anticubism(水题)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。