# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425266 | zoooma13 | The short shank; Redemption (BOI21_prison) | C++14 | 2086 ms | 14256 KiB |
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;
int main()
{
int n ,k ,T;
scanf("%d%d%d",&n,&k,&T);
vector <int> a(n);
for(int&i : a)
scanf("%d",&i);
int ans = 0;
vector <pair<int ,int>> rs ,q;
for(int i = 0; i < n; i++){
while(!q.empty() && q.back().first > T-i)
q.pop_back();
if(a[i] <= T){
while(!q.empty() && q.back().first >= a[i]-i)
q.pop_back();
q.push_back({a[i]-i ,i});
}else if(!q.empty())
rs.push_back({q.back().second ,i-1});
else
ans++;
}
for(int s = 0; s < k && !rs.empty(); s++){
vector <int> cum(n+1);
for(auto&p : rs)
cum[p.first]++ ,cum[p.second+1]--;
for(int i = 0; i <= n; i++)
cum[i] += (i? cum[i-1] : 0);
int rem = max_element(cum.begin() ,cum.end()) - cum.begin();
ans += cum[rem];
vector <pair <int ,int>> new_rs;
for(auto&p : rs) if(rem < p.first || p.second < rem)
new_rs.push_back(p);
rs = new_rs;
}
printf("%d\n",n-ans);
}
Compilation message (stderr)
# | 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... |