結果

問題 No.397 NO MORE KADOMATSU
ユーザー tookunn_1213
提出日時 2016-07-15 23:30:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 27,864 KB
平均クエリ数 661.56
最終ジャッジ日時 2024-07-17 00:07:51
合計ジャッジ時間 2,361 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
N = int(input())
A = [int(i) for i in input().split()]
sys.stdout.flush()
def isKadomatsu(a):
	for i in range(1,len(a) - 1):
		if a[i - 1] < a[i] > a[i + 1] or a[i - 1] > a[i] < a[i + 1]:
			return True
	return False
ans = []
while isKadomatsu(A):
	i = 1
	while i < len(A):
		if A[i - 1] > A[i]:
			ans.append((i - 1,i))
			A[i - 1],A[i] = A[i],A[i - 1]
		i += 1
print(len(ans))
for i in ans:
	u,v = i
	print(u,v)
sys.stdout.flush()
0