杭电2673--shǎ崽 OrOrOrOrz

shǎ崽 OrOrOrOrz

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7821    Accepted Submission(s): 3735

Problem Description

Acmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first.
The problem is :
Give you a sequence of distinct integers, choose numbers as following : first choose the biggest, then smallest, then second biggest, second smallest etc. Until all the numbers was chosen .
For example, give you 1 2 3 4 5, you should output 5 1 4 2 3

Input

There are multiple test cases, each case begins with one integer N(1 <= N <= 10000), following N distinct integers.

Output

Output a sequence of distinct integers described above.

Sample Input

5 1 2 3 4 5

Sample Output

5 1 4 2 3

Author

WhereIsHeroFrom

Source

HDU女生专场公开赛——谁说女子不如男

Recommend

lcy   |   We have carefully selected several similar problems for you:  2672 2674 2668 1040 1236

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <algorithm>
 4 #include <cstring>
 5 using namespace std;
 6 int num[10010];
 7 int main()
 8 {
 9     int n;
10     while(~scanf("%d", &n))
11     {
12         for(int i = 0; i < n; i++)
13             scanf("%d", &num[i]);
14         sort(num, num + n);
15         if(n & 1)
16         {
17             for(int j = 0, i = n-1; i > n/2; j++, i--)
18                 printf("%d %d ", num[i], num[j]);
19             printf("%d\n", num[n/2]);
20         }
21         else
22         {
23             for(int j = 0, i = n-1; i >= n/2; j++, i--)
24             {
25                 if(j == 0)
26                     printf("%d %d", num[i], num[j]);
27                 else
28                     printf(" %d %d", num[i], num[j]);
29             }
30             printf("\n");
31         }
32     }
33
34     return 0;
35 }
时间: 2024-11-05 22:35:34

杭电2673--shǎ崽 OrOrOrOrz的相关文章

[acm]HDOJ 2673 shǎ崽 OrOrOrOrz

题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=2673 拍两次序,交替输出 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 #define MAX_NUMBER 10000 6 bool myfunction1 (int i,int j) { return (i<j); } 7 bool m

hdu 1.3.4 shǎ崽 OrOrOrOrz

简单的排序,注意输出即可 #include <iostream> #include <algorithm> using namespace std; int main() { int a[10001]; int n,i; //int t = 0; while(cin>>n) { //if(t)cout<<endl; //t++; for(i=0; i<n; i++) { cin>>a[i]; } sort(a,a+n); if(n%2==1

HDU2673:shǎ崽 OrOrOrOrz

Problem Description Acmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in Internet bar doing problems overnight. So many girls want to meet and Orz him. But Orz him is not that easy.You must solve this problem first. The problem

hdu 2671 shǎ崽 OrOrOrOrz(排序)

题意:排序后按题目要求输出 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; int main(){ int a[10000],n,i,j; while(~scanf("%d",&n)){ for(i=0;i<n;++i) scanf("%d",&a[i]); sort(a,a+n); i=0

杭电 HDU 1164 Eddy&#39;s research I

Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7117    Accepted Submission(s): 4268 Problem Description Eddy's interest is very extensive, recently  he is interested in prime

hdu 1016 Prime Ring Problem DFS解法 纪念我在杭电的第一百题

Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29577    Accepted Submission(s): 13188 Problem Description A ring is compose of n circles as shown in diagram. Put natural num

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

一个人的旅行 HDU杭电2066【dijkstra算法】

http://acm.hdu.edu.cn/showproblem.php?pid=2066 Problem Description 虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景--草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女--眼看寒假就快到了,这么一大段时间,可不

杭电1162--Eddy&#39;s picture(Prim()算法)

Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8070    Accepted Submission(s): 4084 Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to b