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 ...
随机推荐
- Nginx配置单主机多域名
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; ...
- jquery qrcode参数
{ // render method: 'canvas', 'image' or 'div' render: 'canvas', // version range somewhere in 1 .. ...
- linux配置网卡绑定
1.确定好要绑定的那两个网口 我这边要绑定的是两个业务口 em2.em3 2.配置ifcfg-bond0.em2.em3 3.修改配置文件/etc/modprcode.d/disk.conf 底部添 ...
- AsyncTask异步交互和httpurlconnection结合使用
//网络请求数据 package com.baidu.myutils; import java.io.BufferedReader; import java.io.InputStreamReader; ...
- RHEL6.4编译安装企业级LAMMP平台
一.LAMMP简介 二.使用软件及服务器架构说明 三.配置及安装过程 1.安装arp与httpd 2.安装mysql 3.安装php(php-fpm) 4.安装Xcache ...
- sysctl.conf网络内核参数说明(转)
下面是我的理解,可能有误,仅供参考. 要调优,三次/四次握手必须烂熟于心. client server(SYN_SENT) —> (SYN_RECV ...
- LeetCode 102
方法一:(迭代) /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * ...
- oracle xmltype导入并解析Excel数据--前言
通常,很多的时候,我们需要导入Excel数据到系统中,但是Excel数据需要我们去各种校验,比如身份证校验,手机号码校验等等. 校验失败的数据,提供Excel导出错误原因,提示给用户. 如此,如果校验 ...
- 常见Linux命令的介绍
今天看到了一些Linux命令的英文全称,于是,就总结上来.通过理解英文全称,去更好的理解与记忆Linux命令. 1.ls——List 列举出当前工作目录的内容(文件或文件夹),就跟你在GUI中打开一个 ...
- 传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确。此 RPC 请求中提供了过多的参数。最多应为 2100
出现这个问题的背景是,判断一批激活码在系统中是否已经存在,很傻的一个作法是,把这一批激活码,以in(in (‘ddd‘,‘aaa‘))的形式来处理,导致问题的出现. 后来,查找资料,http://bb ...