codeforces A. Difference Row
link:http://codeforces.com/contest/347/problem/A
开始看起来很复杂的样子,但是刚写下样例,就发现因为中间的都消去了,其实起作用的就是最大值和最小值=_=
#include <cstdio>
#include <algorithm>
using namespace std;
];
int main(void)
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
int n;
while (~scanf("%d", &n))
{
int i;
; i < n; scanf("%d", a+i++));
sort(a, a+n);
printf(]);
; i < n-; ++i)
printf(" %d", a[i]);
printf(]);
}
;
}
排序后输出就行。
codeforces A. Difference Row的更多相关文章
- codeforces A. Difference Row 解题报告
题目链接:http://codeforces.com/problemset/problem/347/A 题目意思:给出一个序列 a1, a2, ..., an , 通过重排序列,假设变成 x1, x2 ...
- CodeForces 347A Difference Row (水题)
题意:给定 n 个数,让你找出一个排列满足每个数相邻作差之和最大,并且要求字典序最小. 析:这个表达式很简单,就是把重新组合一下,就成了x1-xn,那么很简单,x1是最大的,xn是最小的,中间排序就好 ...
- codeforces 347A - Difference Row
给你一个序列,让你求(x1 - x2) + (x2 - x3) + ... + (xn - 1 - xn).值最大的一个序列,我们化简一下公式就会发现(x1 - x2) + (x2 - x3) + . ...
- A. Difference Row
A. Difference Row time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- codeforces round #201 Div2 A. Difference Row
#include <iostream> #include <vector> #include <algorithm> using namespace std; in ...
- RGB 颜色空间转 HSI 颜色空间的matlab程序实现
RGB 颜色空间转 HSI 颜色空间的matlab程序实现 2014.10.20之前的内容有误,这里依据wikipedia更新了算法内容. 算法以wiki为准 https://en.wikipedia ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- Codeforces 903D Almost Difference
Codeforces 903D Almost Difference time limit per test 2 seconds memory limit per test 256 megabytes ...
- Codeforces gym101612 L.Little Difference(枚举+二分)
传送:http://codeforces.com/gym/101612 题意:给定一个数n(<=1e18),将n分解为若干个数的成绩.要求这些数两两之间的差值不能大于1. 分析: 若n==2^k ...
随机推荐
- Copy page via powershell and not save as template 分类: Sharepoint 2015-07-16 16:39 4人阅读 评论(0) 收藏
By save as template informaton of the page get lost, e.g. permissions. To avoid this, use powershell ...
- 【转载】cmake编写
Cmake的输入是在源码目录下的CMakeLists.txt文件.这个文件可以用include或者 add_subdirectory 命令增加入其它的输入文件. 语法 CMakeList.txt文件是 ...
- 在非spring组件中注入spring bean
1.在spring中配置如下<context:spring-configured/> <context:load-time-weaver aspectj-weaving=&q ...
- 内核input子系统分析
打开/driver/input/input.c 这就是input代码的核心 找到 static int __init input_init(void) { err = class_register(& ...
- He faced a maximum sentence of three years.
Police raided his home in August and found more than 100g of marijuana. He faced a maximum sentence ...
- PHP 语法
不过在 PHP 中,所有变量都对大小写敏感. 在下面的例子中,只有第一条语句会显示 $color 变量的值(这是因为 $color.$COLOR 以及 $coLOR 被视作三个不同的变量): 实例 & ...
- HIS-DELPHI-读取数据库配置
产品思维: 1.做成可配置的 2.模块化 医生会有自己熟悉的药品,数据里面药品太多,让医生选择不放便 所以可以让医生自己维护自己的药品模板数据 比如医生开了处方后,可以保存当前的处方到某个模板中,那么 ...
- iOS学习之判断是否有网络的方法
在实际开发中, 会有这样一个需求: 用户在有网的状态下会直接从网络请求数据, 在没网的情况下直接从本地读取数据. 下边的方法可以判断是否有网络. - (BOOL)connectedToNetwork ...
- mysql 同一IP 产生太多终端的数据库连接导致阻塞
问题:null, message from server: "Host 'ip' is blocked because of many connection errors; unblock ...
- leetcode Online Judge 150题 解答分析之一 Reverse Words in a String
问题 Given an input string, reverse the string word by word. For example, Given s = "the sky is b ...