class CostOptimizer: def schedule_jobs(self, jobs): # 按紧急程度分类 urgent = [j for j in jobs if j.deadline < 1_hour] normal = [j for j in jobs if 1_hour <= j.deadline < 6_hours] batch = [j for j in jobs if j.deadline >= 6_hours] # 批量任务享受50%折扣 batch_cost = sum(j.estimated_cost for j in batch) * 0.5 normal_cost = sum(j.estimated_cost for j in normal) * 0.8 urgent_cost = sum(j.estimated_cost for j in urgent) return urgent + normal + batch, batch_cost + normal_cost + urgent_cost