四大文化赛道完整展开
03-execution/run-001/source-snapshot/main.py
main.py
站内文件视图直接读取仓库内容,Markdown 使用文档排版渲染,其余文本文件保持原始排版,方便校对训练证据链。
文件类型.py
10-cases/s2-jh-06-supply-balance/03-execution/run-001/source-snapshot/main.py
import sys
def solve(data: str) -> str:
tokens = list(map(int, data.split()))
if not tokens:
return ""
it = iter(tokens)
n = next(it)
values = [next(it) for _ in range(n)]
total = sum(values)
if total % n != 0:
return "possible=NO"
target = total // n
prefix_diff = 0
moves = 0
units = 0
for index in range(n - 1):
prefix_diff += values[index] - target
if prefix_diff != 0:
moves += 1
units += abs(prefix_diff)
return "\n".join(
[
"possible=YES",
f"moves={moves}",
f"units={units}",
]
)
if __name__ == "__main__":
sys.stdout.write(solve(sys.stdin.read()).strip())
sys.stdout.write("\n")