提交时间:2024-08-21 08:48:34
运行 ID: 175139
#include <bits/stdc++.h> using namespace std; int a[90005]; int main() { int n, m; cin >> n >> m; string s = ""; for (int i = 1; i <= m - 1; i++) cin >> a[i]; int cur = 0; for (int i = m; i <= n; i++) { cin >> a[i]; int maxn = -1; for (int j = cur; j <= i; j++) { if (a[j] > maxn) maxn = a[j]; a[j - 1] = a[j]; } cout << maxn << endl; s += char(maxn + '0'); cur++; } cout << s << endl; return 0; }