链接:传送门

题意:题目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的更多相关文章

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

    题目链接: B. Coat of Anticubism time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. Codeforces Round #349

    终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...

  3. 冬训 day2

    模拟枚举... A - New Year and Buggy Bot(http://codeforces.com/problemset/problem/908/B) 暴力枚举即可,但是直接手动暴力会非 ...

  4. Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack

    #include <iostream> #include <vector> #include <algorithm> using namespace std; in ...

  5. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  6. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  7. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  8. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  9. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

随机推荐

  1. vue 动态添加路由 require.context()

    之前的写法 'use strict' import Vue from 'vue' import MessageBroadcast from 'page/MessageBroadcast' import ...

  2. HDU 4513 吉哥系列故事——完美队形II( Manacher变形 )

    链接:传送门 思路:根据完美队形的定义,可以得知,完美队形实质上是 回文串 + 序列出现峰,因为是在回文串中再次增加了一个要求,所以可以对 Manacher 进行改造,改造的部分应该为暴力匹配的循环 ...

  3. nyoj48-小明的调查作业

    48-小明的调查作业 内存限制:64MB时间限制:1000msSpecial Judge: No accepted:3submit:4 题目描述: 小明的老师布置了一份调查作业,小明想在学校中请一些同 ...

  4. SpringBoot-CommandLineRunner实现预操作

    前提:在使用SpringBoot构建项目时,我们通常需要做一些预先操作(类似开机自启动).而SpringBoot正好提供了一个简单的方式来实现–CommandLineRunner. CommandLi ...

  5. 经常使用的MySQL语句整理

    本文參考:http://www.blogjava.net/bolo 部分自己补充,长期更新 MySQL的SQL语句写法,除了那些主要的之外,另一些也算比較经常使用的,这里记录下来,以便以后查找. 好记 ...

  6. [C#] 怎样分析stackoverflow等clr错误

    有时候由于无限递归调用等代码错误,w3wp.exe会报错退出.原因是clr.exe出错了. 这样的错误比較难分析,由于C#代码抓不住StackOverflowException等异常. 处理方法是:生 ...

  7. Unity3D脚本编程--基本概念

    1. 简单介绍 在Unity3D中,游戏对象(GameObject)的行为是由附加其上的脚本来控制的,游戏开发人员通过编写脚本来控制游戏中的全部对象,如移动Camera等. GameObject能够被 ...

  8. RecyclerView实现底部载入很多其它功能

    这两天在公司没有什么任务分配,就研究了下咱们Google在Android5.0 推出的一个用来取代ListView的列表控件----RecyclerView. 发现功能上确实比ListView强大了不 ...

  9. Regexp-Utils:身份证号校验

    ylbtech-Regexp-Utils:身份证号校验 1.返回顶部 1.方法 var idCardNoUtil = { /*省,直辖市代码表*/ provinceAndCitys: { 11: &q ...

  10. windows2003安装

    产品密钥JCDPY-8M2V9-BR862-KH9XB-HJ3HMiis的i386文件夹http://pan.baidu.com/s/1dD0EY6twindows2003的iso映像http://p ...