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 int INT;
#define pb push_back
#define fst first
#define snd second
#define FOR(i,l,r) for(int i = (l); i < (r); i++)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
vii intervals;
vii idx;
INT GetBestPosition(INT N, INT C, INT R, INT *K, INT *S, INT *E) {
idx.resize(N);
FOR(i, 0, N) idx[i] = {i,i};
FOR(i, 0, C){
intervals.pb({idx[S[i]].fst, idx[E[i]].snd});
idx.erase(idx.begin() +S[i], idx.begin() + E[i]);
idx[S[i]].fst = intervals.back().fst;
}
//for(ii p : intervals) cout << p.fst << " " << p.snd << endl;
vi val(C, -1);
FOR(i, 0, C) FOR(j, intervals[i].fst, intervals[i].snd){
val[i] = max(val[i], K[j]);
}
ii best = {-1, -1e9};
//for(int k : val) cout << k << endl;
FOR(i, 0, N) {
int tot = 0;
FOR(c,0,C) if(intervals[c].fst <= i and i <= intervals[c].snd){
tot += val[c] < R;
}
best = max(best, {tot,-i});
}
return -best.snd;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |