#include <bits/stdc++.h>
using namespace std;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
//printf("here");
vector<int> X;
X.push_back(1);
for(int i = 0; i < N-1; i ++){
if(K[i] < R){
X.push_back(0);
}else{
X.push_back(2);
}
}
int ans = 0;
int bestIndx = -1;
for(int i = 0; i < N; i ++){
vector<int> Y;
for(int j: X){
Y.push_back(j);
}
/*for(int j: Y){
printf("%d", j);
}
printf("\n");
printf("i=%d\n", i);*/
int temp = 0;
for(int j = 0; j < C; j ++){
int max1 = 0;
for(int k = S[j]; k <= E[j]; k ++){
max1 = max(max1, Y[k]);
}
for(int k = S[j]; k <= E[j]; k ++){
Y.erase(Y.begin()+S[j]);
}
temp += (max1 == 1);
Y.insert(Y.begin()+S[j], max1);
/*for(int j: Y){
printf("%d", j);
}
printf("\n");*/
}
//printf("temp=%d\n", temp);
if(temp > ans){
ans = temp;
bestIndx = i;
}
if(i+1 < N){
swap(X[i], X[i+1]);
}
}
return bestIndx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
23 ms |
384 KB |
Output is correct |
4 |
Correct |
23 ms |
384 KB |
Output is correct |
5 |
Correct |
16 ms |
384 KB |
Output is correct |
6 |
Correct |
26 ms |
256 KB |
Output is correct |
7 |
Correct |
24 ms |
256 KB |
Output is correct |
8 |
Correct |
23 ms |
256 KB |
Output is correct |
9 |
Incorrect |
12 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
489 ms |
412 KB |
Output is correct |
2 |
Execution timed out |
1089 ms |
384 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
1404 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |