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 <algorithm>
#include <vector>
using namespace std;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
if (N > 5000) return 0;
vector<int> adjlist[N + C], stuff;
for (int i = 0; i < N; ++i) stuff.push_back(i);
for (int i = 0; i < C; ++i) {
for (int j = S[i]; j <= E[i]; ++j) adjlist[N + i].push_back(stuff[S[i]]), stuff.erase(stuff.begin() + S[i]);
stuff.insert(stuff.begin() + S[i], N + i);
}
int dptable[N + C], ans = -1, mx = -1;
for (int i = 0; i < N; ++i) {
int sm = 0;
fill_n(dptable, N + C, -1);
for (int j = 0; j < N; ++j) {
if (j < i) dptable[j] = K[j];
else if (j == i) dptable[j] = R;
else dptable[j] = K[j - 1];
}
for (int j = N; j < N + C; ++j) {
dptable[j] = -1;
for (int k: adjlist[j]) dptable[j] = max(dptable[j], dptable[k]);
if (dptable[j] == R) ++sm;
}
if (sm > mx) sm = mx, ans = i;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |