結果

問題 No.2463 ストレートフラッシュ
ユーザー hiro1729hiro1729
提出日時 2023-09-09 07:48:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 339 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 79,784 KB
最終ジャッジ日時 2023-09-09 07:49:00
合計ジャッジ時間 7,009 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,100 KB
testcase_01 AC 71 ms
71,060 KB
testcase_02 AC 73 ms
70,872 KB
testcase_03 AC 85 ms
76,248 KB
testcase_04 AC 96 ms
76,556 KB
testcase_05 AC 97 ms
76,444 KB
testcase_06 AC 73 ms
71,136 KB
testcase_07 AC 87 ms
76,160 KB
testcase_08 AC 91 ms
76,352 KB
testcase_09 AC 107 ms
77,192 KB
testcase_10 AC 88 ms
76,176 KB
testcase_11 AC 74 ms
71,056 KB
testcase_12 AC 93 ms
76,444 KB
testcase_13 AC 255 ms
78,916 KB
testcase_14 AC 286 ms
79,116 KB
testcase_15 AC 275 ms
79,040 KB
testcase_16 AC 283 ms
79,168 KB
testcase_17 AC 312 ms
79,616 KB
testcase_18 AC 339 ms
79,444 KB
testcase_19 AC 333 ms
79,448 KB
testcase_20 AC 330 ms
79,452 KB
testcase_21 AC 292 ms
79,344 KB
testcase_22 AC 314 ms
79,784 KB
testcase_23 AC 326 ms
79,448 KB
testcase_24 AC 330 ms
79,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = [[0] * (n + 1) for _ in range(m)]
for i in range(n * m):
	s, t = map(int, input().split())
	s -= 1; t -= 1
	a[t][s] = max(i - 4, 0)
	if s == 0:
		a[t][n] = max(i - 4, 0)
ans = n * m
for i in range(m):
	for j in range(n - 3):
		b = sorted(a[i][j:j + 5])
		t = x = 0
		for k, v in enumerate(b):
			if v <= x:
				continue
			t += (v - x + 4 - k) // (5 - k)
			x += (v - x + 4 - k) // (5 - k) * (5 - k)
		ans = min(ans, t)
print(ans)
0