結果
問題 |
No.1337 Fair Otoshidama
|
ユーザー |
![]() |
提出日時 | 2025-04-28 15:17:45 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 689 bytes |
コンパイル時間 | 226 ms |
コンパイル使用メモリ | 8,192 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2025-04-28 15:17:49 |
合計ジャッジ時間 | 3,775 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 8 |
コンパイルメッセージ
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...10 a = a.map { |x| x % 100 } if i >= 3 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