Codeforces 1189B Number Circle
题目链接: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的更多相关文章
- Codeforces - 1189B - Number Circle - 贪心
https://codeforc.es/contest/1189/problem/B 优先考虑最大的元素怎么构造.拿两个次大的围着他就很好,但是其他的怎么安排呢?就直接降序排列就可以了. a数组还开错 ...
- codeforces Hill Number 数位dp
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits: 5000 MS Memory Limits: ...
- 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 ...
- Codeforces 27E. Number With The Given Amount Of Divisors (暴力)
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...
- Codeforces 235E Number Challenge
http://codeforces.com/contest/235/problem/E 远距离orz......rng_58 证明可以见这里(可能要FQ才能看到) 还是copy一下证明吧: 记 $$f ...
- CodeForces 1151E Number of Components
题目链接:http://codeforces.com/problemset/problem/1151/E 题目大意: n个人排成一个序列,标号为 1~n,第 i 个人的学习成绩为 ai,现在要选出学习 ...
- Codeforces 251C Number Transformation
Number Transformation 我们能发现这个东西是以2 - k的lcm作为一个循环节, 然后bfs就好啦. #include<bits/stdc++.h> #define L ...
- Codeforces 40E Number Table - 组合数学
题目传送门 传送门I 传送门II 题目大意 给定一个$n\times m$的网格,每个格子上要么填$1$,要么填$-1$,有$k$个位置上的数是已经填好的,其他位置都是空的.问有多少种填法使得任意一行 ...
- 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 ...
随机推荐
- C++之前置自增与后置自增
关于前置自增与后置自增的区别我是参考这里:http://bbs.bccn.net/thread-454977-1-1.html 简单复述下,比如++x; 与 x++; 在C中,++x这个表达式的值为原 ...
- ORA-13639: The CURRENT operation was interrupted because it timed OUT
该错误是由于SQL Tune Job执行超时导致,默认“Time Limit"是3600秒,即一个小时.DECLARE l_sql_tune_task_id CLOB; BEGIN ...
- 微信小程序 使用wxParse解析html
微信小程序 加载 HTML 标签:https://blog.csdn.net/zclengendary/article/details/54312030 微信小程序 使用wxParse解析html:h ...
- ASP.NET MVC 学习笔记之面向切面编程与过滤器
AOP(面向切面)是一种架构思想,用于把公共的逻辑放到一个单独的地方,这样就不用每个地方都写重复的代码了.比如程序中发生异常,不用每个地方都try…catch 只要在Golbal的Applicatio ...
- Windows 下安装 nvm 管理 nodejs 版本
摘自https://segmentfault.com/a/1190000007612011 1. 下载安装与使用 Github: Download nvm-windows --- nvm-setup. ...
- Element UI - 打开弹出框(el-dialog)页面会抖动
当 dialog 出现时,页面右边缩小了 5px,模态框看起来会抖动 解决方案 发现 body 多了样式:padding-right: 5px 和 overflow: hidden.紧接着我就在全局设 ...
- hightchart 报错 Error in mounted hook: "Error: Highcharts error #17: www.highcharts.com/errors/17"
这个错误是应该导入hightchart 使用的相关的 东西 ,这里是worldcloud import Wordcloud from 'highcharts/modules/wordclou ...
- redis集群添加新节点
一.创建节点(接上文) 1.在H1服务器/root/soft目录下创建7002目录 2.将7001目录的配置文件redis.conf拷贝到7002,并修改配置文件的端口 3.进入 redis-5.0. ...
- Flume速览
Flume是一个分布式的.可靠的.高可用的海量日志采集.聚合和传输的系统.Java实现,插件丰富,模块分明. 数据流模型:Source-Channel-Sink 事务机制保证了消息传递的可靠性 一.基 ...
- Java中使用try-catch-finally处理IO流中的异常
我们使用try-catch-finally来接收IO流的异常 finally是最后执行的步骤,非常适合最后存放close来关闭IO流,而且编程中我们不可以随意抛出异常,必须对异常进行处理. 从try- ...