結果
| 問題 | 
                            No.1337 Fair Otoshidama
                             | 
                    
| コンテスト | |
| ユーザー | 
                             toshiro_yanagi
                         | 
                    
| 提出日時 | 2025-04-28 15:18:42 | 
| 言語 | Ruby  (3.4.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 691 bytes | 
| コンパイル時間 | 393 ms | 
| コンパイル使用メモリ | 8,224 KB | 
| 実行使用メモリ | 13,184 KB | 
| 最終ジャッジ日時 | 2025-04-28 15:18:46 | 
| 合計ジャッジ時間 | 3,504 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 13 WA * 7 | 
コンパイルメッセージ
Syntax OK
ソースコード
class Main
  def start
    a = input.split.map { |s| s.to_i + 100 }
    puts main(a) ? "Yes" : "No"
    return nil
  end
  private
  def main(a)
    result = false
    return result if a.sum % 3 != 0
    target = a.sum / 3
    for i in 0...100
      a = a.map { |x| x % 100 } if i >= 10
      a = sub(a, i % 3, a[0] == target)
      if a.min == a.max
        result = true
        break
      end
    end
    result
  end
  def sub(a, i, flg)
    target = a.sum / 3
    j = 1 + i
    x = [a[j % 3] + (i != 2 || flg ? 0 : j) - target, 0].max / j * j
    a[i] += x
    a[j % 3] -= x
    #puts [j, target, x, a].flatten.join(", ")
    return a
  end
  def input = gets
end
Main.new.start
            
            
            
        
            
toshiro_yanagi