#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 10005;
const int mod = 1e9 + 7;
int n, r, a[MAXN], b[MAXN];
int Do(int r, int s){
for(int i=0; i<r; i++){
for(int j=0; j<n; j++){
if(a[j] > a[j+n]) swap(a[j], a[j+n]);
}
swap(a[0], a[n]);
rotate(a, a + 1, a + n);
}
int pos = (find(a, a + 2 * n, s) - a);
return pos % n;
}
int main(){
scanf("%d %d",&n,&r);
for(int i=0; i<2*n; i++){
scanf("%d",&b[i]);
}
r = (r % (2 * n)) + 2 * n;
pi ret(1e9, 1e9);
for(int i=0; i<n; i++){
vector<int> foo(b, b + 2 * n);
rotate(foo.begin(), foo.begin() + 1, foo.begin() + 2 * i + 1);
for(int i=0; i<n; i++){
a[i] = foo[2*i];
a[i+n] = foo[2*i+1];
}
ret = min(ret, pi(Do(r, b[0]), -i));
}
cout << 1-ret.second << endl;
}
Compilation message
archery.cpp: In function 'int main()':
archery.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
25 | scanf("%d %d",&n,&r);
| ~~~~~^~~~~~~~~~~~~~~
archery.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
27 | scanf("%d",&b[i]);
| ~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Execution timed out |
2078 ms |
384 KB |
Time limit exceeded |
3 |
Correct |
7 ms |
384 KB |
Output is correct |
4 |
Execution timed out |
2076 ms |
384 KB |
Time limit exceeded |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
31 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
40 ms |
256 KB |
Output is correct |
3 |
Execution timed out |
2076 ms |
384 KB |
Time limit exceeded |
4 |
Execution timed out |
4 ms |
512 KB |
Time limit exceeded (wall clock) |
5 |
Runtime error |
5 ms |
1024 KB |
Execution killed with signal 11 |
6 |
Correct |
31 ms |
384 KB |
Output is correct |
7 |
Execution timed out |
2077 ms |
384 KB |
Time limit exceeded |
8 |
Runtime error |
5 ms |
896 KB |
Execution killed with signal 11 |
9 |
Execution timed out |
4 ms |
640 KB |
Time limit exceeded (wall clock) |
10 |
Execution timed out |
2087 ms |
384 KB |
Time limit exceeded |
11 |
Execution timed out |
4 ms |
640 KB |
Time limit exceeded (wall clock) |
12 |
Execution timed out |
2081 ms |
384 KB |
Time limit exceeded |
13 |
Execution timed out |
5 ms |
768 KB |
Time limit exceeded (wall clock) |
14 |
Execution timed out |
2069 ms |
512 KB |
Time limit exceeded |
15 |
Execution timed out |
7 ms |
768 KB |
Time limit exceeded (wall clock) |
16 |
Correct |
59 ms |
384 KB |
Output is correct |
17 |
Execution timed out |
2066 ms |
384 KB |
Time limit exceeded |
18 |
Execution timed out |
2053 ms |
384 KB |
Time limit exceeded |
19 |
Execution timed out |
2074 ms |
384 KB |
Time limit exceeded |
20 |
Execution timed out |
2060 ms |
512 KB |
Time limit exceeded |
21 |
Execution timed out |
5 ms |
640 KB |
Time limit exceeded (wall clock) |
22 |
Execution timed out |
4 ms |
768 KB |
Time limit exceeded (wall clock) |
23 |
Execution timed out |
5 ms |
768 KB |
Time limit exceeded (wall clock) |
24 |
Correct |
38 ms |
256 KB |
Output is correct |
25 |
Execution timed out |
2090 ms |
384 KB |
Time limit exceeded |
26 |
Execution timed out |
2089 ms |
512 KB |
Time limit exceeded |
27 |
Execution timed out |
4 ms |
640 KB |
Time limit exceeded (wall clock) |
28 |
Execution timed out |
5 ms |
768 KB |
Time limit exceeded (wall clock) |
29 |
Execution timed out |
2083 ms |
384 KB |
Time limit exceeded |
30 |
Execution timed out |
2076 ms |
512 KB |
Time limit exceeded |
31 |
Execution timed out |
4 ms |
640 KB |
Time limit exceeded (wall clock) |
32 |
Execution timed out |
5 ms |
768 KB |
Time limit exceeded (wall clock) |
33 |
Correct |
54 ms |
376 KB |
Output is correct |
34 |
Correct |
34 ms |
376 KB |
Output is correct |
35 |
Execution timed out |
2092 ms |
384 KB |
Time limit exceeded |
36 |
Execution timed out |
2084 ms |
384 KB |
Time limit exceeded |
37 |
Execution timed out |
4 ms |
512 KB |
Time limit exceeded (wall clock) |
38 |
Execution timed out |
4 ms |
640 KB |
Time limit exceeded (wall clock) |
39 |
Correct |
52 ms |
376 KB |
Output is correct |
40 |
Execution timed out |
2070 ms |
384 KB |
Time limit exceeded |
41 |
Execution timed out |
2095 ms |
384 KB |
Time limit exceeded |
42 |
Execution timed out |
2083 ms |
384 KB |
Time limit exceeded |
43 |
Execution timed out |
2077 ms |
512 KB |
Time limit exceeded |
44 |
Runtime error |
5 ms |
896 KB |
Execution killed with signal 11 |
45 |
Execution timed out |
4 ms |
640 KB |
Time limit exceeded (wall clock) |
46 |
Runtime error |
5 ms |
896 KB |
Execution killed with signal 11 |
47 |
Execution timed out |
6 ms |
768 KB |
Time limit exceeded (wall clock) |