結果

問題 No.397 NO MORE KADOMATSU
ユーザー tonnnura172tonnnura172
提出日時 2020-04-24 15:16:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 977 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 25,940 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 02:34:52
合計ジャッジ時間 2,207 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
25,844 KB
testcase_01 AC 51 ms
25,460 KB
testcase_02 AC 45 ms
25,120 KB
testcase_03 AC 45 ms
25,888 KB
testcase_04 AC 47 ms
25,220 KB
testcase_05 AC 49 ms
25,544 KB
testcase_06 AC 49 ms
25,684 KB
testcase_07 AC 48 ms
25,200 KB
testcase_08 AC 45 ms
25,092 KB
testcase_09 AC 43 ms
25,344 KB
testcase_10 AC 68 ms
25,940 KB
testcase_11 AC 45 ms
25,676 KB
testcase_12 AC 58 ms
25,792 KB
testcase_13 AC 60 ms
25,764 KB
testcase_14 AC 59 ms
25,732 KB
testcase_15 AC 58 ms
25,900 KB
testcase_16 AC 46 ms
25,596 KB
testcase_17 AC 44 ms
25,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

ans = []
for i in range(N):
	for j in range(N-1, i, -1):
		if A[j-1] > A[j]:
			ans.append((j, j-1))
			A[j], A[j-1] = A[j-1], A[j]
if not ans:
	print(0)
else:
	print(len(ans))
	for op in ans:
		print(*op)
0