結果
| 問題 |
No.2463 ストレートフラッシュ
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-09-11 20:35:51 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 927 ms / 2,000 ms |
| コード長 | 792 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 14,336 KB |
| 最終ジャッジ日時 | 2024-06-29 10:20:55 |
| 合計ジャッジ時間 | 14,337 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
N, M = gets.split.map(&:to_i)
memo = Array.new(M + 1) { Array.new(N + 2, Float::INFINITY) }
1.upto(N * M) do |t|
n, m = gets.split.map(&:to_i)
if t <= 5
t = 0
else
t -= 5
end
memo[m][n] = t if memo[m][n] > t
if n == 1
memo[m][N + 1] = t if memo[m][N + 1] > t
end
end
ans = Float::INFINITY
1.upto(M) do |m|
1.upto(N - 4) do |n|
cards = memo[m][n..n + 4].sort
draw_cnt = 5
cur = 0
cnt = 0
while cards.size > 0
while cards.size > 0 && cards[0] <= cur
cards.shift
draw_cnt -= 1
end
if draw_cnt > 0
next_i = cards[0]
len = next_i - cur
c = (len + draw_cnt - 1) / draw_cnt
cnt += c
cur += c * draw_cnt
end
end
ans = cnt if ans > cnt
end
end
puts ans
siman