이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 2e6 + 6;
int a[N];
int ct[N];
int low[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, d, t;
cin >> n >> d >> t;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
stack<int> stk;
for (int i = 1; i <= n; ++i) {
stk.push(i);
while (!stk.empty() && a[stk.top()] + i - stk.top() > t) {
stk.pop();
}
low[i] = (stk.empty() ? n + 1 : stk.top());
}
for (int iter = 1; iter <= d; ++iter) {
int mx = 1;
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
if (low[j] < i) {
ct[i]++;
if (ct[i] > ct[mx]) {
mx = i;
}
}
}
}
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; ++j) {
if (low[j] < i) {
ct[i]--;
}
}
}
for (int j = mx; j <= n; ++j) {
if (low[j] < mx) {
low[j] = n + 1;
}
}
}
int ans = 0;
for (int i = 1; i <= n; ++i) {
if (low[i] <= n) {
ans++;
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |