結果

問題 No.2463 ストレートフラッシュ
ユーザー sasa8uyauyasasa8uyauya
提出日時 2023-09-08 23:03:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 95,472 KB
最終ジャッジ日時 2023-09-08 23:04:17
合計ジャッジ時間 18,346 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,388 KB
testcase_01 AC 65 ms
71,560 KB
testcase_02 AC 68 ms
71,212 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 113 ms
77,356 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 119 ms
77,592 KB
testcase_11 WA -
testcase_12 AC 133 ms
77,948 KB
testcase_13 AC 956 ms
88,372 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1,313 ms
94,996 KB
testcase_20 AC 1,286 ms
94,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1,144 ms
94,456 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
c=[[] for i in range(m)]
for i in range(n*m):
	s,t=map(int,input().split())
	s-=1
	t-=1
	c[t].append((i,s))
for i in range(m):
	c[i].sort()
a=n*m
for _ in range(2):
	for i in range(m):
		q=[-1]*(n+1)
		for p,x in c[i]:
			q[x]=p
			for j in range(x-4,x+1):
				if 0<=j<j+4<=n:
					g=[-1]+q[j:j+5]
					g.sort()
					if all([gg>=0 for gg in g[1:]]):
						b=0
						for k in range(5):
							b+=(g[k+1]-g[k]-1+5-k-1)//(5-k)
						a=min(a,b)
	for i in range(m):
		for j in range(len(c[i])):
			if c[i][j][1]==0:
				c[i][j]=(c[i][j][0],n)
print(a)
0