shǎ崽 OrOrOrOrz |
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
Total Submission(s): 3859 Accepted Submission(s): 1195 |
|
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.
|
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 51 2 3 4 5
|
Sample Output 5 1 4 2 3 |
presentation有点麻烦,其他还好
#include<iostream>
#include<string>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
int n,nt,temp;
vector<int> stor;
while( cin>>n)
{
stor.clear();
nt=n;
while(nt>0)
{
nt--;
cin>>temp;
stor.push_back(temp);
}
int h=0,t=n-1;
sort(stor.begin(),stor.end());
while(t>=h)
{
cout<<stor[t--];
if(h<=t)
cout<<" ";
if(t>=h)
cout<<stor[h++];
if(h<=t)
cout<<" ";
}
cout<<endl;
}
return 0;
}