最小排列
在每个给定的数字输出前按从小到大的顺序输出所有比它小的数字
#pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #include<string.h> #include<stdlib.h> #include<vector> #include<algorithm> #include<iostream> #include<map> #include<queue> #include<stack> #include<string> #include<functional> #include<math.h> //#include<bits/stdc++.h> using namespace std; typedef long long lint; typedef vector<int> VI; typedef pair<int, int> PII; typedef queue<int> QI; void makedata() { freopen("input.txt", "w", stdout); fclose(stdout); } int a[110000]; bool f[110000]; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif //makedata(); std::ios::sync_with_stdio(0), cin.tie(0); int n, m, x; memset(f, false, sizeof(f)); cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a[i]; f[a[i]] = true; } int p = 1; for (int i = 0; i < m; i++) { for (int j = p; j < a[i]; j++) { if (!f[j]) { cout << j << endl; } } cout << a[i] << endl; p = max(p, a[i]); while (f[p]) p++; } for (int i = p; i <= n; i++) cout << i << endl; return 0; }