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)
{
for(i=0; i<=(n-2)/2; i++)
cout<<a[n-i-1]<<" "<<a[i]<<" ";
cout<<a[i];
}
else
{
for(i=0; i<=(n-2)/2; i++)
{
if(i==(n-1)/2)
cout<<a[n-i-1]<<" "<<a[i];
else
{
cout<<a[n-i-1]<<" "<<a[i]<<" ";
}
}
}
cout<<endl;

}
return 0;
}

hdu 1.3.4 shǎ崽 OrOrOrOrz

时间: 2024-10-01 02:50:59

hdu 1.3.4 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

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

杭电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

hdu2637

shǎ崽 OrOrOrOrz Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3654 Accepted Submission(s): 1138   Problem Description Acmer in HDU-ACM team are ambitious, especially shǎ崽, he can spend time in In

hdu 3308 LCIS(线段树区间合并)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5792    Accepted Submission(s): 2513 Problem Description Given n integers. You have two

hdu 3345 War Chess (bfs+优先队列)

War Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1732    Accepted Submission(s): 416 Problem Description War chess is hh's favorite game: In this game, there is an N * M battle map, an

hdu 3415 单调队列

Max Sum of Max-K-sub-sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5690    Accepted Submission(s): 2059 Problem Description Given a circle sequence A[1],A[2],A[3]......A[n]. Circle s

HDU 3415 Max Sum of Max-K-sub-sequence(单调队列)

Problem Description Given a circle sequence A[1],A[2],A[3]......A[n]. Circle sequence means the left neighbour of A[1] is A[n] , and the right neighbour of A[n] is A[1]. Now your job is to calculate the max sum of a Max-K-sub-sequence. Max-K-sub-sequ