#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
vi arr;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
int levo[N], desno[N], gol[N], ans[N];
gol[N-1] = 0;
for(int i = 0; i < N; i++){
ans[i] = 0;
levo[i] = i;
desno[i] = i;
if(i < N-1)
gol[i] = K[i];
}
for(int i = 0; i < C; i++){
int l = S[i], r = E[i], tl = S[i], tr = E[i];
for(int j = l; j <= r; j++){
tl = min(tl, levo[i]);
tr = min(tr, desno[i]);
}
int big = 0, best_ans = 0;
for(int j = tl; j <= tr; j++){
big = max(big, gol[j]);
best_ans = max(best_ans, ans[j]);
}
if(big <= R){
for(int j = tl; j <= tr; j++){
ans[j] = best_ans + 1;
gol[j] = R;
levo[j] = tl;
desno[j] = tr;
}
}
else{
for(int j = tl; j <= tr; j++){
ans[j] = best_ans;
gol[j] = big;
levo[j] = tl;
desno[j] = tr;
}
}
}
int rez = 0;
for(int i = 0; i < N; i++){
rez = max(rez, ans[i]);
}
return rez-1;
// return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |