四大文化赛道完整展开
03-execution/run-001/source-snapshot/main.py
main.py
站内文件视图直接读取仓库内容,Markdown 使用文档排版渲染,其余文本文件保持原始排版,方便校对训练证据链。
文件类型.py
10-cases/s2-jh-02-livelihood-trend/03-execution/run-001/source-snapshot/main.py
import sys
def round_half_up(total: int, count: int) -> int:
return (2 * total + count) // (2 * count)
def solve(data: str) -> str:
tokens = list(map(int, data.split()))
if not tokens:
return ""
n = tokens[0]
values = tokens[1:1 + n]
total_change = values[-1] - values[0]
longest = 1
current = 1
for index in range(1, n):
if values[index] > values[index - 1]:
current += 1
else:
current = 1
if current > longest:
longest = current
recent = values[-min(3, n):]
forecast = round_half_up(sum(recent), len(recent))
return "\n".join(
[
f"total_change={total_change}",
f"longest_rise={longest}",
f"forecast={forecast}",
]
)
if __name__ == "__main__":
sys.stdout.write(solve(sys.stdin.read()).strip())
sys.stdout.write("\n")