zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    NYOJ458
    NYOJ67
    NYOJ105
    NYOJ1071
    NYOJ463
    C语言练字用小软件 — Practise_Calligraphy_1.0(ANSI)
    NYOJ276
    NYOJ455
    NYOJ74
    Jzoj4458 密钥破解——Pollard-rho
  • 原文地址:https://www.cnblogs.com/WArobot/p/6725822.html
Copyright © 2011-2022 走看看