結果
問題 | No.1935 Water Simulation |
ユーザー |
|
提出日時 | 2022-05-13 22:27:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 670 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 82,536 KB |
実行使用メモリ | 61,220 KB |
最終ジャッジ日時 | 2024-07-22 04:35:39 |
合計ジャッジ時間 | 2,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
import sys from collections import defaultdict sys.setrecursionlimit(10 ** 7) def get_list(ty=int): return list(map(ty, input().split())) def get_int(): return int(input()) def get_str(): return input() V1, V2, V3, V4, N = get_list() V = [V1, V2, V3, V4] def smart(V): C = [0] * 4 C[0] = V[0] history = defaultdict(int) for n in range(N): a = n % 4 b = (n + 1) % 4 diff = min(V[b] - C[b], C[a]) C[a] -= diff C[b] += diff if history[tuple(C)] >= 100 and (n + 1) % 4 == N % 4: break history[tuple(C)] += 1 return C print(" ".join(str(c) for c in smart(V)))