题目链接:http://codeforces.com/problemset/problem/1189/B


AC代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
int a[maxn];
int b[maxn];
int c[maxn];
bool check(int i)
{
if(a[i] < a[i-]+a[i+]) return true;
else return false;
}
int main()
{
int n;
cin >> n;
for(int i = ;i < n;i++)
{
cin >> a[i];
}
sort(a,a+n);
int b1 = ,c1 = ;
for(int i = ;i < n;i++)
{
if(i% == ) c[c1++] = a[i];
else b[b1++] = a[i];
}
for(int i = ;i < c1;i++)
{
a[i] = c[i];
}
for(int i = c1;i < n;i++)
{
a[i] = b[--b1];
}
bool flag = true;
for(int i = ;i < n-;i++)
{
if(!check(i)) flag = false;
}
if(!flag || a[n-] >= a[] + a[n-] || a[] >= a[n-] + a[]) cout << "NO";
else
{
cout << "YES" << endl;
for(int i = ;i < n;i++)
{
cout << a[i] << " ";
}
}
return ;
}

Codeforces 1189B Number Circle的更多相关文章

  1. Codeforces - 1189B - Number Circle - 贪心

    https://codeforc.es/contest/1189/problem/B 优先考虑最大的元素怎么构造.拿两个次大的围着他就很好,但是其他的怎么安排呢?就直接降序排列就可以了. a数组还开错 ...

  2. codeforces Hill Number 数位dp

    http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits: ...

  3. codeforces 27E Number With The Given Amount Of Divisors

    E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...

  4. Codeforces 27E. Number With The Given Amount Of Divisors (暴力)

    题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...

  5. Codeforces 235E Number Challenge

    http://codeforces.com/contest/235/problem/E 远距离orz......rng_58 证明可以见这里(可能要FQ才能看到) 还是copy一下证明吧: 记 $$f ...

  6. CodeForces 1151E Number of Components

    题目链接:http://codeforces.com/problemset/problem/1151/E 题目大意: n个人排成一个序列,标号为 1~n,第 i 个人的学习成绩为 ai,现在要选出学习 ...

  7. Codeforces 251C Number Transformation

    Number Transformation 我们能发现这个东西是以2 - k的lcm作为一个循环节, 然后bfs就好啦. #include<bits/stdc++.h> #define L ...

  8. Codeforces 40E Number Table - 组合数学

    题目传送门 传送门I 传送门II 题目大意 给定一个$n\times m$的网格,每个格子上要么填$1$,要么填$-1$,有$k$个位置上的数是已经填好的,其他位置都是空的.问有多少种填法使得任意一行 ...

  9. Codeforces 235E. Number Challenge DP

    dp(a,b,c,p) = sigma ( dp(a/p^i,b/p^j,c/p^k) * ( 1+i+j+k) ) 表示用小于等于p的素数去分解的结果有多少个 E. Number Challenge ...

随机推荐

  1. JdbcTemplate 的oracle分页

    @Autowired private JdbcTemplate jd; int ps1=Integer.valueOf(pageSize); int cp1=Integer.valueOf(currP ...

  2. Excel2016怎么批量删除空白行 如何删除空白行

    我们在编辑Excel文档的时候,如果表格中有大量的空白行,这时我们怎么样把它们批量删除呢?下面我们就一起来看看操作的方法吧.   工具/原料   Excel2016 方法/步骤     首先在电脑上打 ...

  3. 其他信息: 未能加载文件或程序集“WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一个依赖项。找 到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

    记录一下,发布web时遇到的一些问题. 一.报错信息: 其他信息: 未能加载文件或程序集“WebGrease, Version=1.5.1.25624, Culture=neutral, Public ...

  4. 算法刷题笔记-stack-四则运算

    题目描述: 给定一个含有数字和运算符的字符串,为表达式添加括号,改变其运算优先级以求出不同的结果.你需要给出所有可能的组合的结果.有效的运算符号包含 +, - 以及 * . 示例 1: 输入: &qu ...

  5. upc组队赛14 Evolution Game【dp】

    Evolution Game 题目描述 In the fantasy world of ICPC there are magical beasts. As they grow, these beast ...

  6. Cocos2d-x 发布 Android

    Cocos2d-x 发布 Android 前置需求: Android NDK Android SDK OR Eclipse ADT Bundle Android AVD target installe ...

  7. Linux折腾

    安装了一圈发行版,最后发现还是Fedora最稳定 debian安装后无法启动 openSUSE源不完善 manjaro重启就进不去

  8. position: relative 和 position: absoution 的详解

    position属性指定一个元素(静态的,相对的,绝对或固定)的定位方法的类型 relative:生成相对定位的元素,相对于其正常位置进行定位. 对应下图的偏移 absolute: 生成绝对定位的元素 ...

  9. SQL查询条件生成小工具

    最近运维数据,经常遇到需要在sql条件中个In('',''....)个字符串的情况,于是在网上找了个小工具改造一下,先用着: 效果如图: using System; using System.Coll ...

  10. Redis事务 和 pipleline

    1.reidis事务 Redis 事务可以一次执行多个命令, 并且带有以下三个重要的保证: 批量操作在发送 EXEC 命令前被放入队列缓存. 收到 EXEC 命令后进入事务执行,事务中任意命令执行失败 ...