結果
| 問題 | No.1337 Fair Otoshidama |
| コンテスト | |
| ユーザー |
toshiro_yanagi
|
| 提出日時 | 2025-04-30 10:00:19 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 2,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 7,936 KB |
| 実行使用メモリ | 12,928 KB |
| 最終ジャッジ日時 | 2025-04-30 10:00:23 |
| 合計ジャッジ時間 | 3,364 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
コンパイルメッセージ
Syntax OK
ソースコード
class Start
def main
a = input.split.map { |s| s.to_i + 100 }
echo func(a) ? "Yes" : "No"
return nil
end
private
def func(a)
result = false
#return result if a.sum % 3 != 0
#echo "j, target, x ,a"
for i in 0...4
k = [0, a.min - 3].max
a = a.map { |x| x - k }
a = sub(a, i % 3)
end
result = true if a.sum % 3 == 0
result
end
def sub(a, i)
target = a.sum / 3
j = 1 + i
x = [a[j % 3] - target, 0].max / j * j
a[i] += x
a[j % 3] -= x
#echo [j, target, x, a]
return a
end
def echo(*x)
print(*x)
puts
end
def input = gets.chomp
end
Start.new.main
toshiro_yanagi