# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
406892 | Ruxandra985 | The short shank; Redemption (BOI21_prison) | C++14 | 165 ms | 20876 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>
#define DIMN 2000010
using namespace std;
int v[DIMN] , w[DIMN] , f[DIMN] , out[DIMN];
pair <int , int> ev[2 * DIMN] , idk[DIMN];
priority_queue <int> h;
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , d , t , sol , i , elem = 0 , e = 0 , pmax , j;
fscanf (fin,"%d%d%d",&n,&d,&t);
sol = 0;
for (i = 1 ; i <= n ; i++){
fscanf (fin,"%d",&v[i]);
if (v[i] > t){
w[++elem] = i;
}
else sol++;
}
for (i = 1 ; i <= n ; i++){
if (v[i] < t){
/// cauti in w intervalul de influenta
pmax = min(n , i + t - v[i]);
ev[++e] = make_pair(i , i);
ev[++e] = make_pair(pmax + 1 , -i);
}
}
sort (ev + 1 , ev + e + 1);
i = 1;
j = 1;
while (j <= elem){
while (i <= e && ev[i].first <= w[j]){
/// procesezi ev[i]
if (ev[i].second > 0)
h.push(ev[i].second);
else {
out[-ev[i].second] = 1; /// il scoti
}
i++;
}
/// acum vezi w[j] ce tata are
while (!h.empty() && out[h.top()])
h.pop();
if (!h.empty())
f[h.top()]++; /// h.top e cel mai din dreapta care il afecteaza pe w[j]
j++;
}
for (i = 1 ; i <= n ; i++){
idk[i] = make_pair(f[i] , i);
}
sort (idk + 1 , idk + n + 1);
for (i = 1 ; i <= n - d ; i++)
sol += idk[i].first;
fprintf (fout,"%d",sol);
return 0;
}
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... |