四大文化赛道完整展开
03-execution/run-001/source-snapshot/main.py
main.py
站内文件视图直接读取仓库内容,Markdown 使用文档排版渲染,其余文本文件保持原始排版,方便校对训练证据链。
文件类型.py
10-cases/s1-jh-01-heritage-costing/03-execution/run-001/source-snapshot/main.py
import math
import sys
def solve(data: str) -> str:
tokens = data.split()
if not tokens:
return ""
it = iter(tokens)
n = int(next(it))
total_sheets = 0
total_cost = 0.0
best_name = ""
best_sheets = -1
best_cost = 0.0
for _ in range(n):
name = next(it)
base_need = int(next(it))
batches = int(next(it))
waste_rate = int(next(it))
unit_price = float(next(it))
sheets = math.ceil(base_need * batches * (100 + waste_rate) / 100.0)
cost = sheets * unit_price
total_sheets += sheets
total_cost += cost
if sheets > best_sheets or (sheets == best_sheets and name < best_name):
best_name = name
best_sheets = sheets
best_cost = cost
return "\n".join(
[
f"total_sheets={total_sheets}",
f"total_cost={total_cost:.2f}",
f"max_item={best_name} {best_sheets} {best_cost:.2f}",
]
)
if __name__ == "__main__":
sys.stdout.write(solve(sys.stdin.read()).strip())
sys.stdout.write("\n")