結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,508 KB
testcase_01 AC 70 ms
71,516 KB
testcase_02 AC 69 ms
71,256 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 117 ms
77,624 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 120 ms
77,580 KB
testcase_11 WA -
testcase_12 AC 131 ms
77,936 KB
testcase_13 AC 943 ms
88,448 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1,302 ms
94,820 KB
testcase_20 AC 1,318 ms
94,372 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1,181 ms
94,344 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*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