結果

問題 No.2463 ストレートフラッシュ
ユーザー ニックネーム
提出日時 2023-09-08 22:17:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,680 KB
実行使用メモリ 78,840 KB
最終ジャッジ日時 2024-06-26 15:23:06
合計ジャッジ時間 4,995 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = [[0]*(n+1) for _ in range(m)]
for t in range(n*m):
    j,i = map(int,input().split())
    a[i-1][j-1] = max(t-4,0)
    if j==1: a[i-1][n] = max(t-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