注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

告别迷茫

梦想与现实的差距,就是我们生活的意义。因为我们有差距,我们才会一直积累,在努力。

 
 
 

日志

 
 

2014年03月31日  

2014-03-31 22:04:38|  分类: HDU |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

shǎ崽 OrOrOrOrz

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


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
 

Recommend
lcy   |   We have carefully selected several similar problems for you:  2672 2674 2668 1106 1209 
 

#include<iostream>
#include<deque>
#include<algorithm>
using namespace std;

int main()
{
int n,i,m;
while(cin>>n)
{
deque<int> w;
for(i=0;i<n;i++)
{
cin>>m;
w.push_front(m);
}
sort(w.begin(),w.end());
int flag=1;
while(1)
{
if(flag==1)
{
cout<<w.back();
w.pop_back();
}
else
{
cout<<w.front();
w.pop_front();
}
flag=!flag;
if(w.empty()) break;
cout<<" ";
}
cout<<endl;
}
return 0;
}


  评论这张
 
阅读(2)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017