比赛 集训 评测结果 WWAWAAWAWW
题目名称 遵循指令之意 最终得分 40
用户昵称 IMZ 运行时间 1.247 s
代码语言 C++ 内存使用 6.94 MiB
提交时间 2025-07-03 11:20:40
显示代码纯文本
#include<bits/stdc++.h>//用long long 
using namespace std;
int a[1000010];
int j[1000010];
int o[1000010];
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	int n;
	scanf("%d",&n);
	int ij=0,ii=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(i%2){
			ij++;ii++;
			j[ij]=a[i];
		}
		else{
			ii++;
			o[ij]=a[i];
		}
	}
	sort(j+1,j+1+ij);
	if(n%2)  ij--;
	sort(o+1,o+1+ij);
	for(int i=1;i<=ii;i++){
		if(i%2){
			printf("%d ",j[i/2+1]);
		} 
		else{
			printf("%d ",o[i/2]);
		}
	}
	return 0;
}