結果

問題 No.2463 ストレートフラッシュ
ユーザー mkawa2mkawa2
提出日時 2023-09-08 22:01:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 1,250 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 79,852 KB
最終ジャッジ日時 2023-09-08 22:01:50
合計ジャッジ時間 6,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,176 KB
testcase_01 AC 70 ms
71,272 KB
testcase_02 AC 72 ms
71,348 KB
testcase_03 AC 76 ms
76,048 KB
testcase_04 AC 90 ms
76,580 KB
testcase_05 AC 89 ms
76,644 KB
testcase_06 AC 72 ms
71,268 KB
testcase_07 AC 78 ms
76,016 KB
testcase_08 AC 88 ms
76,684 KB
testcase_09 AC 99 ms
77,612 KB
testcase_10 AC 82 ms
75,788 KB
testcase_11 AC 72 ms
71,184 KB
testcase_12 AC 88 ms
76,528 KB
testcase_13 AC 236 ms
79,024 KB
testcase_14 AC 260 ms
79,040 KB
testcase_15 AC 280 ms
79,144 KB
testcase_16 AC 261 ms
79,192 KB
testcase_17 AC 295 ms
79,424 KB
testcase_18 AC 313 ms
79,708 KB
testcase_19 AC 341 ms
79,740 KB
testcase_20 AC 316 ms
79,732 KB
testcase_21 AC 276 ms
79,852 KB
testcase_22 AC 287 ms
79,788 KB
testcase_23 AC 325 ms
79,792 KB
testcase_24 AC 316 ms
79,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = -1-(-1 << 63)
# md = 10**9+7
md = 998244353

def solve(b,s):
    pp=[]
    for a in range(s,s+5):
        if a==n:a=0
        pp.append(pos[b][a])
    pp.sort(reverse=True)
    now=0
    cnt=0
    while pp:
        d=len(pp)
        p=pp.pop()
        c=(p+1-now+d-1)//d
        cnt+=c
        now+=c*d
        while pp and pp[-1]<now:p=pp.pop()
    return cnt-1

n,m=LI()
pos=[[0]*n for _ in range(m)]
for i in range(n*m):
    a,b=LI1()
    pos[b][a]=i
ans=inf
for b in range(m):
    for a in range(n-3):
        ans=min(ans,solve(b,a))

print(ans)
0