Codeforces 667B Coat of Anticubism
链接:传送门
题意:题目balabala说了一大堆,然而并没什么卵用,给你n个数,将这个集合分割成两部分,构成三角形的两个边,让你求补充的那个边最短是多长
思路:三角形三边具有 a + b > c,如果想让补充的边最短,只需要在集合中选出最大的一个值a,然后让剩余值的和为c,那 min_b = a-c+1
/*************************************************************************
> File Name: test.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年04月17日 星期一 18时35分48秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[100010];
int main(){
int n;
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++) scanf("%lld",a+i);
sort(a,a+n);
LL ma = a[n-1];
LL sum = 0;
for(int i=0;i<n-1;i++) sum += a[i];
cout<<ma-sum+1<<endl;
}
return 0;
}
Codeforces 667B Coat of Anticubism的更多相关文章
- codeforces 667B B. Coat of Anticubism(水题)
题目链接: B. Coat of Anticubism time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces Round #349
终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...
- 冬训 day2
模拟枚举... A - New Year and Buggy Bot(http://codeforces.com/problemset/problem/908/B) 暴力枚举即可,但是直接手动暴力会非 ...
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
随机推荐
- 在小程序中实现全局混入,以混入的形式扩展小程序的api
GitHub: https://github.com/WozHuang/mp-extend 相关文章: 小程序全局状态管理,在页面中获取globalData和使用globalSetData 通过页面预 ...
- flex笔记 - 基础
flex笔记 - 基础 文章中的所有图示代码都放在了github上: 阮一峰flex博客跟学代码 传统的布局解决方案,基于盒模型, 依赖 display, position, float属性来进行布局 ...
- Mac python3 环境下 完善pdf转jpg脚本
由于样本图片数据都是保存在pdf里,想拿到样本必须先把图片从pdf中提取出来,算是数据清洗中的一点小小的积累吧. 这里不得不吐槽一下公司存储图片的机制,业务员把jpg格式的照片放到word里,然后用工 ...
- Emgu cv人脸检测识别
Emgu cv人脸检测识别 1.开发平台:WIN10 X64 VS2012 Emgucv版本:3.1 2.先给大家分享一个官网给的示例源代码: https://ncu.dl.sourcef ...
- PHP学习总结(3)——PHP入门篇之PHP的echo语句
Echo语句 echo是PHP中的输出语句,可以把字符串输出(字符串用双引号括起来). 如下代码: <?php echo "Hello world!";?> 注意ech ...
- rabbitMQ学习笔记(三) 消息确认与公平调度消费者
从本节开始称Sender为生产者 , Recv为消费者 一.消息确认 为了确保消息一定被消费者处理,rabbitMQ提供了消息确认功能,就是在消费者处理完任务之后,就给服务器一个回馈,服务器就会将 ...
- 关于idea控制台乱码问题
乱码是常有的事儿,改一下也就两分钟......不多说看图: 上图中的勾选项一定不要忘记,它可以隐藏你项目中encoding设置. 在上图两个文件中加入 -Dfile.encoding=UTF-8 在上 ...
- zoj 3034 - The Bridges of Kolsberg
题目:在河两端有两排server,如今要把河两边同样的品牌型号的机器连起来.每一个电脑有个值, 每一个机器仅仅能与还有一台机器链接.而且不同的链接不交叉,如今要求链接的电脑总之最大. 分析:dp,最大 ...
- 远程视频监控之驱动篇(LED)
转载请注明出处:http://blog.csdn.net/ruoyunliufeng/article/details/38515205 之前一直在考虑该不该写这篇,由于我之前在博客里有写过LED的驱动 ...
- Codeforces Round #282 (Div. 1)B. Obsessive String KMP+DP
B. Obsessive String Hamed has recently found a string t and suddenly became quite fond of it. He s ...