0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 22:58:48 +00:00

#1199. 90岁的张哥哥 [70pts]

https://sjzezoj.com/submission/46089
This commit is contained in:
Baoshuo Ren 2021-12-26 19:53:16 +08:00
parent eb55455755
commit 390e2c36f5
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

34
S2OJ/1199/1199.cpp Normal file
View File

@ -0,0 +1,34 @@
#pragma GCC optimize("Ofast")
#include <algorithm>
#include <iostream>
#include <limits>
using std::cin;
using std::cout;
using std::endl;
const int N = 300005;
int n, c, l, r, a[N];
bool vis[N];
int main() {
std::ios::sync_with_stdio(false);
cin >> n >> c;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
l = 1, r = c;
for (int i = 1; i <= n; i++) {
int p = std::min_element(a + l, a + r + 1) - a;
cout << a[p] << ' ';
vis[p] = true;
a[p] = std::numeric_limits<int>::max();
while (p && vis[p]) p--;
l = std::max(p, 1);
r = std::min(r + 1, n);
}
cout << endl;
return 0;
}