CodeForces 347 A. Difference Row
来源:互联网 发布:信息技术软件应用方法 编辑:程序博客网 时间:2024/06/05 06:21
观察给出的式子特点,可以发现只需要找到最小值和最大值即可
然后把剩余的数据从小到达输出即可
代码如下:
#include <cstdio>#include <iostream>#include <algorithm>#define MAXN 10010#define ll long longusing namespace std;int a[MAXN];int main(void) { int n; int mina = 10000; int maxa = -10000; while(cin >> n) { for(int i=0; i<n; ++i) { cin >> a[i]; mina = min(mina, a[i]); maxa = max(maxa, a[i]); } sort(a, a+n); cout << a[n-1]; for(int i=1; i<n-1; ++i) { printf(" %d", a[i]); } printf(" %d\n", a[0]); }}
0 0
- codeforces 347A - Difference Row
- CodeForces 347 A. Difference Row
- Codeforces 347 A. Difference Row
- CodeForces 347A Difference Row
- CodeForces 347A Difference Row
- Codeforces Round #201 (Div. 2) 347A Difference Row(脑洞)
- Difference Row(347A)
- Codeforces Round #201 (Div. 2) A. Difference Row
- A. Difference Row
- CodeForces 347A Difference(水题)
- Difference Row
- codeforces Trees in a Row
- Pearls in a Row CodeForces
- Trees in a Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- Five-In-a-Row CodeForces
- 类目、扩展和协议
- ZOJ 3708 Density of Power Network
- HDU 1290 献给杭电五十周年校庆的礼物
- 学习总结--委托和事件
- Leetcode_max-points-on-a-line(c++ and python version)
- CodeForces 347 A. Difference Row
- 点类派生直线类
- JavaScript实现弹窗报错
- web前端开发与页面设计的协作、区别与发展
- 读《魔鬼搭讪学》有感
- Darwin Streaming Server 核心代码分析
- 字符串反转
- 电影汇总
- 浅谈C\C++代码优化中的一些小技巧