题解
2023-06-24 13:56:00
发布于:上海
67阅读
0回复
0点赞
#include <iostream>
#include <queue>
using namespace std;
int q[501], n, maxx, h, t, a;
long long k, cnt;
int main() {
cin >> n >> k >> a;
maxx = a;
for (int i = 1; i < n; i++) {
int x;
cin >> x;
q[t++] = x;
maxx = max(maxx, x);
}
if (k > n) {
cout << maxx;
} else {
while (cnt != k) {
if (a > q[h]) {
cnt++;
q[t++] = q[h++];
} else {
cnt = 0;
a = q[h++];
}
}
cout << a;
}
return 0;
}
这里空空如也
有帮助,赞一个