結果
問題 | No.832 麻雀修行中 |
ユーザー |
![]() |
提出日時 | 2021-01-24 12:46:55 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 7,936 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2025-01-02 16:08:41 |
合計ジャッジ時間 | 3,890 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 25 |
コンパイルメッセージ
Syntax OK
ソースコード
def check_2x7(a) cnt = (0..4).map { a.count(_1) } cnt == [3, 0, 7, 0, 0] end def check_3x4(a) flag = true (0...10).each do |i| a[i] -= 3 if a[i] >= 3 if a[i] > 0 minus = a[i] (i...i + 3).each do |j| if j < 10 if minus > a[j] flag = false break end a[j] -= minus else flag = false end end end end flag end def check(a) flag = false flag = true if check_2x7(a.dup) (0...10).each do |i| if a[i] >= 2 a[i] -= 2 flag = true if check_3x4(a.dup) a[i] += 2 end end flag end s = gets.chomp.chars.map(&:to_i) a = (0...10).map { s.count(_1) } puts (0...10).select { |i| if i >= 1 && a[i] <= 3 a[i] += 1 res = check(a.dup) # p [a, res] a[i] -= 1 res else false end }