이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 1<<21;
int a[N];
int b[N];
int n, d, t;
priority_queue<int> pq;
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n >> d >> t;
int lst = 1e9+10;
Loop (i,0,n) {
cin >> a[i];
b[i] = min(lst+1, a[i]);
lst = b[i];
}
int cnt = 0;
int ans = 0;
Loop (i,0,n) {
if (a[i] > t && b[i] <= t) {
++cnt;
} else {
if (cnt)
pq.push(cnt);
cnt = 0;
}
if (b[i] <= t)
++ans;
}
if (cnt)
pq.push(cnt);
while (pq.size() && d--) {
ans -= pq.top();
pq.pop();
}
cout << ans << '\n';
}
# | 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... |