結果

問題 No.397 NO MORE KADOMATSU
ユーザー TawaraTawara
提出日時 2016-07-20 21:17:04
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 444 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 6,460 KB
実行使用メモリ 24,468 KB
平均クエリ数 501.89
最終ジャッジ日時 2023-09-23 11:12:10
合計ジャッジ時間 3,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
23,628 KB
testcase_01 AC 36 ms
23,448 KB
testcase_02 AC 37 ms
23,388 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 36 ms
24,240 KB
testcase_10 AC 36 ms
23,400 KB
testcase_11 AC 36 ms
23,676 KB
testcase_12 AC 43 ms
23,676 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 35 ms
24,060 KB
testcase_17 AC 36 ms
24,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdout
def iskadomatsu(a,b,c):
	return b>a>c or b>c>a or b<a<c or b<c<a
N = int(raw_input())
A = map(int,raw_input().split())
M = 0
op = []
for i in xrange(N-2):
	if iskadomatsu(A[i],A[i+1],A[i+2]):break
else:
	print 0
	stdout.flush()
	input()
	quit()
for i in xrange(N):
	for j in xrange(i+1,N):
		if A[j]<A[j-1]:
			A[j-1],A[j]=A[j],A[j-1]
			M+=1
			op.append([j-1,j])
print M
for u,v in op:
	print u,v
stdout.flush()
input()
0