比赛 期末考试3 评测结果 C
题目名称 hope I can be awake 最终得分 0
用户昵称 xuyuqing 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2026-02-11 10:57:12
显示代码纯文本

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

class fastIn {
	private:
	
	char buf [1 << 20];
	char *p1 = buf;
	char *p2 = buf;
	
	inline char getch ();
	
	public:
	
	template <typename NumT>
	void read (NumT &num);
	
	template <typename NumT>
	fastIn& operator >> (NumT &num);
};

inline char fastIn::getch () {
	if (p1 == p2) {
		p1 = buf;
		p2 = buf + fread (buf, 1, 1 << 20, stdin);
		if (p1 == p2) {
			return EOF;
		}
	}
	return *p1++;
}

template <typename NumT>
void fastIn::read (NumT &num) {
	char ch = getch ();
	NumT op = 1;
	num = 0;
	
	while (ch < '0' || '9' < ch) {
		op = ((ch == '-') ? -1 : 1);
		ch = getch ();
	}
	while ('0' <= ch && ch <= '9') {
		num *= 10;
		num += (ch - '0');
		ch = getch ();
	}
	
	num *= op;
}

template <typename NumT>
fastIn& fastIn::operator >> (NumT &num) {
	read (num);
	return *this;
}

fastIn fin;

constexpr int N = 233233;

int n;
int k;
vector<int> nums;
vector<int> other;
bool flag[N];

int main () {

	freopen ("hopeicanbeawake.in", "r", stdin);
	freopen ("hopeicanbeawake.out", "w", stdout);

	fin >> n >> k;
	for (int i = 1; i <= k; i++) {
		int num;
		fin >> num;
		nums.push_back(num);
		flag[num] = true;
	}

	for (int i = 1; i <= n; i++) {
		if (!flag[i]) {
			other.push_back(i);
		}
	}

	int it = 0;
	for (int i = 0 ; i < nums.size() - 1; i++) {
		printf ("%d ", nums[i]);
		if (it != other.size() && other[it] < nums[i]) {
			printf ("%d ", other[it]);
			it++;
		}
	}

	other.push_back(*nums.rbegin());
	sort (other.begin() + it, other.end(), greater ());
	for (; it < other.size(); it++) {
		printf ("%d ", other[it]);
	}
	
	return 0;
}