N, S = map(int,input().split())
A = list(map(int,input().split()))
operations = []
for i in range(N):
for j in range(N-i-1):
if A[j] > A[j+1]:
operations.append((j,j+1))
operations.append((j+1,j))
operations.append((j,j+1))
A[j], A[j+1] = A[j+1], A[j]
print(len(operations))
for i, j in operations: print(i+1, j+1)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2816 KB |
Output is correct |
2 |
Correct |
19 ms |
2796 KB |
Output is correct |
3 |
Correct |
20 ms |
3180 KB |
Output is correct |
4 |
Correct |
44 ms |
4224 KB |
Output is correct |
5 |
Correct |
49 ms |
4460 KB |
Output is correct |
6 |
Correct |
45 ms |
4332 KB |
Output is correct |
7 |
Correct |
45 ms |
4332 KB |
Output is correct |
8 |
Correct |
45 ms |
4332 KB |
Output is correct |
9 |
Correct |
48 ms |
4460 KB |
Output is correct |
10 |
Correct |
47 ms |
4460 KB |
Output is correct |
11 |
Correct |
20 ms |
2944 KB |
Output is correct |
12 |
Correct |
73 ms |
5720 KB |
Output is correct |
13 |
Correct |
74 ms |
5720 KB |
Output is correct |
14 |
Correct |
73 ms |
5848 KB |
Output is correct |
15 |
Correct |
72 ms |
5720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2816 KB |
Output is correct |
2 |
Correct |
19 ms |
2796 KB |
Output is correct |
3 |
Correct |
20 ms |
3180 KB |
Output is correct |
4 |
Correct |
44 ms |
4224 KB |
Output is correct |
5 |
Correct |
49 ms |
4460 KB |
Output is correct |
6 |
Correct |
45 ms |
4332 KB |
Output is correct |
7 |
Correct |
45 ms |
4332 KB |
Output is correct |
8 |
Correct |
45 ms |
4332 KB |
Output is correct |
9 |
Correct |
48 ms |
4460 KB |
Output is correct |
10 |
Correct |
47 ms |
4460 KB |
Output is correct |
11 |
Correct |
20 ms |
2944 KB |
Output is correct |
12 |
Correct |
73 ms |
5720 KB |
Output is correct |
13 |
Correct |
74 ms |
5720 KB |
Output is correct |
14 |
Correct |
73 ms |
5848 KB |
Output is correct |
15 |
Correct |
72 ms |
5720 KB |
Output is correct |
16 |
Correct |
16 ms |
2796 KB |
Output is correct |
17 |
Correct |
47 ms |
4460 KB |
Output is correct |
18 |
Correct |
70 ms |
5464 KB |
Output is correct |
19 |
Correct |
69 ms |
5464 KB |
Output is correct |
20 |
Correct |
66 ms |
5464 KB |
Output is correct |
21 |
Correct |
67 ms |
5464 KB |
Output is correct |
22 |
Correct |
69 ms |
5592 KB |
Output is correct |
23 |
Correct |
69 ms |
5592 KB |
Output is correct |
24 |
Correct |
68 ms |
5484 KB |
Output is correct |
25 |
Correct |
68 ms |
5464 KB |
Output is correct |
26 |
Incorrect |
113 ms |
7768 KB |
Integer 59568 violates the range [0, 40000] |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2796 KB |
Output is correct |
2 |
Correct |
19 ms |
2796 KB |
Output is correct |
3 |
Correct |
20 ms |
3180 KB |
Output is correct |
4 |
Correct |
68 ms |
5464 KB |
Output is correct |
5 |
Execution timed out |
1095 ms |
86588 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |