This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
const int N = 2e6+5;
int n, a[N], d, t;
int main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> d >> t;
int ans = 0;
int cnt = 0;
multiset<int, greater<>> s;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] = (a[i] <= t);
if (a[i]) {
ans++;
s.insert(cnt);
cnt = 0;
} else {
cnt++;
}
}
if (!ans) {
cout << ans << "\n";
return 0;
}
s.insert(cnt);
ans = n;
int x = min(sz(s), d);
while (x--) {
ans -= *s.begin();
s.erase(s.begin());
}
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... |