結果

問題 No.2463 ストレートフラッシュ
ユーザー rlangevinrlangevin
提出日時 2023-09-08 21:55:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 79,684 KB
最終ジャッジ日時 2023-09-08 21:56:20
合計ジャッジ時間 6,536 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,268 KB
testcase_01 AC 74 ms
71,224 KB
testcase_02 AC 72 ms
71,184 KB
testcase_03 AC 81 ms
76,564 KB
testcase_04 AC 86 ms
76,300 KB
testcase_05 WA -
testcase_06 AC 76 ms
75,572 KB
testcase_07 AC 82 ms
76,588 KB
testcase_08 AC 86 ms
76,436 KB
testcase_09 AC 90 ms
76,872 KB
testcase_10 AC 84 ms
76,280 KB
testcase_11 AC 78 ms
76,264 KB
testcase_12 AC 86 ms
76,572 KB
testcase_13 AC 262 ms
78,696 KB
testcase_14 WA -
testcase_15 AC 273 ms
78,704 KB
testcase_16 AC 282 ms
79,080 KB
testcase_17 AC 341 ms
79,260 KB
testcase_18 AC 333 ms
79,684 KB
testcase_19 AC 336 ms
79,460 KB
testcase_20 AC 362 ms
79,036 KB
testcase_21 AC 293 ms
79,480 KB
testcase_22 AC 314 ms
79,476 KB
testcase_23 AC 322 ms
79,344 KB
testcase_24 AC 355 ms
79,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
ind = [[-1] * (N + 1) for i in range(M)]
for i in range(N * M):
    n, m = map(int, input().split())
    n, m = n - 1, m - 1
    ind[m][n] = i
    
for m in range(M):
    ind[m][-1] = ind[m][0]
   

def solve(A):
    now = 0
    card = 0
    cnt = 0
    while card != 5:
        nex = A[card]
        d = 5 - card
        n = (nex - now + d - 1)//d
        now += d * n
        cnt += n
        card = 0
        for i in range(5):
            if A[i] <= now:
                card += 1
    return cnt - 1
            
            

ans = 10 ** 18 
for m in range(M):
    for i in range(N - 3):
        L = []
        for j in range(5):
            L.append(ind[m][i + j])
        L.sort()
        ans = min(ans, solve(L))
        
print(ans)
0