题目链接: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. 数据访问层的接口IBaseDAL

    using System; using System.Collections; using System.Data; using System.Data.Common; using System.Co ...

  2. 通过angular.js实现MVC的基本步骤

    通过ng实现MVC的基本步骤: ①创建模块 var app = angular.module('模块名字',['依赖模块1','依赖模块2']) ②调用模块 ngApp--> ng-app=&q ...

  3. Linux部署web项目

    一.软件1.putty2.WinSCP 二.调试1.linux 下 apache启动.停止.重启命令基本的操作方法:本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合 ...

  4. Optparse 简介

    optparse 这个库的主要作用是可以用为脚本提供传递命令参数功能 一个简单的例子 def main(): parser = OptionParser(usage = "usage: %p ...

  5. Python之字典中的键映射多个值

    字典的键值是多个,那么就可以用列表,集合等来存储这些 键值 举例 print({"key":list()}) # {'key': []} print({"key" ...

  6. LeetCode Array Easy 217. Contains Duplicate

    Description Given an array of integers, find if the array contains any duplicates. Your function sho ...

  7. (转)OpenGL学习——立方体贴图

    转自:https://learnopengl-cn.readthedocs.io/zh/latest/04%20Advanced%20OpenGL/06%20Cubemaps/ 我们之前一直使用的是2 ...

  8. teb教程8

    融合动态障碍物 简介:考虑怎样把其他节点发布的动态障碍物考虑进来 1.本部分演示了动态障碍物该如何被包含到teb_local_planner中. 2.写一个简单的动态障碍物的发布器publish_dy ...

  9. 每天一个Linux常用命令 cat命令

    在Linux系统中,cat命令是一个文本输出命令,通常用来查看某个文档的内容.它有如下三个功能: 1.一次性显示整个文件 如:查看/etc/initab文件,可以使用命令:cat/etc/initta ...

  10. STL_Algorithm

    #include <algorithm> #include <cstdio> using namespace std; /*虽然最后一个排列没有下一个排列,用next_perm ...