#include <bits/stdc++.h>
using namespace std;
const int nx=205;
int n, r, res=INT_MAX, st;
vector<int> p(2*nx), pw(2*nx), npw(2*nx);
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>r;
//r=(r%n)+2*n;
for (int i=0; i<2*n; i++) cin>>p[i];
for (int i=0; i<2*n; i++)
{
pw[i]=p[0];
for (int j=0; j<i; j++) pw[j]=p[j+1];
for (int j=i+1; j<2*n; j++) pw[j]=p[j];
for (int t=0; t<r; t++)
{
for (int j=2; j<2*n; j+=2)
{
if (pw[j]<pw[j+1]) npw[j-2]=pw[j], npw[j+1]=pw[j+1];
else npw[j-2]=pw[j+1], npw[j+1]=pw[j];
}
if (pw[0]<pw[1]) npw[1]=pw[0], npw[2*(n-1)]=pw[1];
else npw[1]=pw[1], npw[2*(n-1)]=pw[0];
pw=npw;
}
//cout<<"st "<<i<<": ";
//for (int j=0; j<2*n; j++) cout<<pw[j]<<' ';
//cout<<'\n';
for (int j=0; j<2*n; j++)
{
if (pw[j]==p[0])
{
if (j/2<res) res=j/2, st=(i/2)+1;
}
}
}
cout<<res+1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Execution timed out |
2090 ms |
348 KB |
Time limit exceeded |
3 |
Execution timed out |
2062 ms |
348 KB |
Time limit exceeded |
4 |
Execution timed out |
2098 ms |
348 KB |
Time limit exceeded |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Execution timed out |
2094 ms |
348 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Execution timed out |
2086 ms |
348 KB |
Time limit exceeded |
3 |
Execution timed out |
2033 ms |
344 KB |
Time limit exceeded |
4 |
Execution timed out |
2053 ms |
348 KB |
Time limit exceeded |
5 |
Runtime error |
4 ms |
1116 KB |
Execution killed with signal 11 |
6 |
Execution timed out |
2094 ms |
348 KB |
Time limit exceeded |
7 |
Execution timed out |
2066 ms |
348 KB |
Time limit exceeded |
8 |
Execution timed out |
2051 ms |
344 KB |
Time limit exceeded |
9 |
Execution timed out |
2070 ms |
348 KB |
Time limit exceeded |
10 |
Execution timed out |
2073 ms |
348 KB |
Time limit exceeded |
11 |
Execution timed out |
2053 ms |
348 KB |
Time limit exceeded |
12 |
Execution timed out |
2062 ms |
348 KB |
Time limit exceeded |
13 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |
14 |
Execution timed out |
2078 ms |
348 KB |
Time limit exceeded |
15 |
Execution timed out |
2052 ms |
604 KB |
Time limit exceeded |
16 |
Incorrect |
72 ms |
348 KB |
Output isn't correct |
17 |
Execution timed out |
2098 ms |
348 KB |
Time limit exceeded |
18 |
Execution timed out |
2061 ms |
348 KB |
Time limit exceeded |
19 |
Execution timed out |
2039 ms |
344 KB |
Time limit exceeded |
20 |
Execution timed out |
2091 ms |
348 KB |
Time limit exceeded |
21 |
Execution timed out |
2045 ms |
344 KB |
Time limit exceeded |
22 |
Execution timed out |
2033 ms |
600 KB |
Time limit exceeded |
23 |
Runtime error |
4 ms |
1116 KB |
Execution killed with signal 11 |
24 |
Incorrect |
37 ms |
464 KB |
Output isn't correct |
25 |
Execution timed out |
2070 ms |
348 KB |
Time limit exceeded |
26 |
Execution timed out |
2066 ms |
348 KB |
Time limit exceeded |
27 |
Execution timed out |
2051 ms |
348 KB |
Time limit exceeded |
28 |
Runtime error |
3 ms |
1116 KB |
Execution killed with signal 11 |
29 |
Execution timed out |
2094 ms |
348 KB |
Time limit exceeded |
30 |
Execution timed out |
2066 ms |
348 KB |
Time limit exceeded |
31 |
Execution timed out |
2061 ms |
348 KB |
Time limit exceeded |
32 |
Runtime error |
4 ms |
1112 KB |
Execution killed with signal 11 |
33 |
Correct |
83 ms |
440 KB |
Output is correct |
34 |
Execution timed out |
2045 ms |
344 KB |
Time limit exceeded |
35 |
Execution timed out |
2045 ms |
348 KB |
Time limit exceeded |
36 |
Execution timed out |
2039 ms |
348 KB |
Time limit exceeded |
37 |
Execution timed out |
2075 ms |
348 KB |
Time limit exceeded |
38 |
Execution timed out |
2071 ms |
604 KB |
Time limit exceeded |
39 |
Execution timed out |
2051 ms |
344 KB |
Time limit exceeded |
40 |
Execution timed out |
2063 ms |
348 KB |
Time limit exceeded |
41 |
Execution timed out |
2091 ms |
348 KB |
Time limit exceeded |
42 |
Execution timed out |
2077 ms |
348 KB |
Time limit exceeded |
43 |
Execution timed out |
2055 ms |
344 KB |
Time limit exceeded |
44 |
Execution timed out |
2077 ms |
348 KB |
Time limit exceeded |
45 |
Execution timed out |
2064 ms |
348 KB |
Time limit exceeded |
46 |
Execution timed out |
2037 ms |
504 KB |
Time limit exceeded |
47 |
Runtime error |
4 ms |
1116 KB |
Execution killed with signal 11 |