結果
| 問題 | No.1935 Water Simulation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-20 08:51:14 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 2,000 ms |
| + 710µs | |
| コード長 | 825 bytes |
| 記録 | |
| コンパイル時間 | 701 ms |
| コンパイル使用メモリ | 95,980 KB |
| 実行使用メモリ | 81,920 KB |
| 最終ジャッジ日時 | 2026-08-20 08:51:20 |
| 合計ジャッジ時間 | 4,480 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
V0,V1,V2,V3,N = map(int,input().split())
V = [V0,V1,V2,V3]
cnt = 0
A = set()
A.add((V0,0,0,0,0))
B = [V0,0,0,0]
while cnt<N:
ind = cnt%4
indn = (cnt+1)%4
delta = min(B[ind],V[indn]-B[indn])
B[ind] = B[ind]-delta
B[indn] = B[indn]+delta
cnt += 1
a = tuple(B+[cnt%4])
if a in A:break
A.add(a)
if cnt==N:
print(*B)
else:
B1 = B[:]
T = cnt
while True:
ind = T%4
indn = (T+1)%4
delta = min(B1[ind],V[indn]-B1[indn])
B1[ind] -= delta
B1[indn] += delta
T += 1
if B1+[T%4]==B+[cnt%4]:
break
T -= cnt
r = (N-cnt)%T
for _ in range(r):
ind = cnt%4
indn = (cnt+1)%4
delta = min(B[ind],V[indn]-B[indn])
B[ind] -= delta
B[indn] += delta
cnt += 1
print(*B)