#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
const int maxn = 2020;
int n, r, p = 0, a[maxn], cur[maxn], sp = 0;
array<int, 2> ans = {100000, -1};
void check() {
for(int i = 0; i < n; i++) cur[i] = a[i];
//for(int i = 0; i < n; i++) cout << cur[i] << " "; cout << endl;
for(int it = 0; it < r; it++) {
#pragma GCC ivdep
for(int i = 1; i < n; i += 2) if(cur[i] < cur[i-1]) swap(cur[i], cur[i-1]);
#pragma GCC ivdep
for(int i = 2; i < n; i++) swap(cur[i], cur[i-1]);
}
int pos = 0;
while(cur[pos]) pos++;
ans = min(ans, {pos, -sp});
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> r;
n *= 2;
r = r%(2*n);
r += 2*n;
cin >> p;
for(int i = 1; i < n; i++) {
cin >> a[i];
}
for(int i = 1; i < n; i++) {
a[i] = a[i] < p ? -1 : 1;
}
check();
for(int i = 1; i < n; i++) {
swap(a[i], a[i-1]);
sp++;
check();
}
cout << 1 + ((-ans[1])/2) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Execution timed out |
2087 ms |
364 KB |
Time limit exceeded |
3 |
Correct |
239 ms |
364 KB |
Output is correct |
4 |
Execution timed out |
2087 ms |
364 KB |
Time limit exceeded |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1396 ms |
396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
364 KB |
Output is correct |
2 |
Execution timed out |
2087 ms |
364 KB |
Time limit exceeded |
3 |
Execution timed out |
2083 ms |
364 KB |
Time limit exceeded |
4 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
5 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
6 |
Execution timed out |
2094 ms |
364 KB |
Time limit exceeded |
7 |
Execution timed out |
2064 ms |
364 KB |
Time limit exceeded |
8 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
9 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
10 |
Execution timed out |
2088 ms |
364 KB |
Time limit exceeded |
11 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
12 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
13 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
14 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
15 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
16 |
Correct |
1129 ms |
492 KB |
Output is correct |
17 |
Incorrect |
617 ms |
404 KB |
Output isn't correct |
18 |
Incorrect |
761 ms |
492 KB |
Output isn't correct |
19 |
Execution timed out |
2070 ms |
364 KB |
Time limit exceeded |
20 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
21 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
22 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
23 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
24 |
Execution timed out |
2084 ms |
364 KB |
Time limit exceeded |
25 |
Execution timed out |
2090 ms |
364 KB |
Time limit exceeded |
26 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
27 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
28 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
29 |
Incorrect |
289 ms |
364 KB |
Output isn't correct |
30 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
31 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
32 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
33 |
Execution timed out |
2078 ms |
364 KB |
Time limit exceeded |
34 |
Correct |
1611 ms |
396 KB |
Output is correct |
35 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
36 |
Incorrect |
1874 ms |
408 KB |
Output isn't correct |
37 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
38 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
39 |
Correct |
1624 ms |
396 KB |
Output is correct |
40 |
Execution timed out |
2047 ms |
364 KB |
Time limit exceeded |
41 |
Incorrect |
22 ms |
364 KB |
Output isn't correct |
42 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
43 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
44 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
45 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
46 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |
47 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 |