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的概 ...
随机推荐
- idea使用lombok
1.这玩意可以帮助我们自动实现set.get方法,实现过程有两处,只要理解了这两处,对其实际工作如何使用就非常简单了 2.第一点就是编译过程,比如使用gradle build 等编译工具进行编译时,会 ...
- pycharm 永久激活 序列码 破解版
如今人工智能的概念相当火爆,很多想学习编程求得高薪岗位的同志纷纷学起了Python,自带的idle不够智能,推荐使用pycharm编辑运行Python程序. 然而小萌新在安装pycharm时才会意识到 ...
- Ubuntu14.04 Anaconda
我虚拟机Ubuntu14.04上的Python已经存在了两个版本,一个是python 2.7,一个是Python 3.4.想在它上面安装Anaconda,但又有所顾虑.我先想到的是,先卸载Ubuntu ...
- JSON 基础学习1
http://www.360doc.com/content/10/0809/22/2633_44873063.shtml JSON转字符串: json.stringify(jsonobj); 字符串转 ...
- HDU 2439 The Mussels
The Mussels Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID ...
- NHibernate之旅(18):初探代码生成工具使用
本节内容 引入 代码生成工具 结语 引入 我们花了大量的篇幅介绍了相关NHibernate的知识.一直都是带着大家手动编写代码,首先创建数据库架构.然后编写持久化类和映射文件,最后编写数据操作方法.測 ...
- [Tailwind] Style Elements on hover and focus with Tailwind’s State Variants
In this lesson, we learn how to target specific states of elements and apply styles only when those ...
- BZOJ 2818 Gcd (莫比乌斯反演 或 欧拉函数)
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MB Submit: 2534 Solved: 1129 [Submit][Status][Discu ...
- 因一段JavaScript代码引发的闲扯
前两天,一朋友给我发了一段JavaScript代码: function f1(){ var n=999; nAdd=function(){ n+=1 }; function f2(){ alert(n ...
- hashmap的put方法源码分析
put主源码如下: public V put(K key, V value) { if (key == null) return putForNullKey(value); int hash = ha ...