結果
| 問題 |
No.1935 Water Simulation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-13 21:38:59 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 494 bytes |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-07-22 01:11:48 |
| 合計ジャッジ時間 | 4,008 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 3 |
コンパイルメッセージ
Syntax OK
ソースコード
a, b, c, d, n = gets.split.map(&:to_i)
as = [a, b, c, d]
xs = [a, 0, 0, 0]
hash = {}
hash[xs] = 0
len = 1
n.times do |i|
i %= 4
j = (i + 1) % 4
h = [xs[i], as[j] - xs[j]].min
xs[i] -= h
xs[j] += h
break if hash[xs]
hash[xs] = len
len += 1
end
tail = hash[xs]
cycle = len - tail
m = tail + (n - tail) % cycle
xs = [a, 0, 0, 0]
m.times do |i|
i %= 4
j = (i + 1) % 4
h = [xs[i], as[j] - xs[j]].min
xs[i] -= h
xs[j] += h
end
puts xs.join(" ")