Submission #467077

#TimeUsernameProblemLanguageResultExecution timeMemory
467077MVP_HarryThe short shank; Redemption (BOI21_prison)C++17
0 / 100
70 ms7888 KiB
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define rep(i, m, n) for (int i = m; i <= n; i++)
#define per(i, m, n) for (int i = m; i >= n; i--)
#define sz(v) (int) v.size()
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

const int maxn = 2e6 + 5;

int N, D, T;
int t[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N >> D >> T;
	rep(i, 1, N) cin >> t[i];
	int ptr = 1, ans = 0;
	vector<int> num;
	while (ptr <= N) {
		if (t[ptr] <= T) {
			ptr++;
			continue;
		}
		int j = ptr + 1;
		while (j <= N && t[j] > T) {
			j++;
		}
		if (ptr == 1) ans += j - ptr;
		else num.push_back(j - ptr);
		ptr = j;
	}
	sort(all(num), greater<int>());
	rep(i, 0, min(D - 1, sz(num) - 1)) ans += num[i];
	cout << N - ans << endl;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...