#include <bits/stdc++.h>
using namespace std;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
vector<int> ans(N, 0);
for (int i = 0; i < N; i++){
vector<int> a;
a.reserve(N);
for (int j = 0; j < i; j++) a.push_back(K[j]);
a.push_back(R);
for (int j = i; j < N - 1; j++) a.push_back(K[j]);
for (int it = 0; it < C; it++){
int mx = 0;
for (int j = S[it]; j <= E[it]; j++){
mx = max(mx, a[j]);
}
if (mx == R) ans[i]++;
a[S[it]] = mx;
a.erase(a.begin() + S[it] + 1, a.begin() + E[it] + 1);
}
}
int pos = max_element(ans.begin(), ans.end()) - ans.begin();
return pos;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
8 ms |
204 KB |
Output is correct |
4 |
Correct |
8 ms |
204 KB |
Output is correct |
5 |
Correct |
2 ms |
296 KB |
Output is correct |
6 |
Correct |
11 ms |
300 KB |
Output is correct |
7 |
Correct |
8 ms |
204 KB |
Output is correct |
8 |
Correct |
9 ms |
204 KB |
Output is correct |
9 |
Correct |
2 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
300 KB |
Output is correct |
2 |
Execution timed out |
1086 ms |
332 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1063 ms |
1740 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |