Codeforces Round #433 (Div. 2) - C. Planning(贪心+链表)

本文介绍了一个关于航班调度的问题,考虑到因技术问题导致的初始延误,需重新安排航班的起飞时间以最小化总延误成本。通过贪心策略,文章探讨了如何合理安排航班以达到最优解。

C. Planning
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.

Metropolis airport is the main transport hub of Metropolia, so it is difficult to keep the schedule intact. This is exactly the case today: because of technical issues, no flights were able to depart during the first k minutes of the day, so now the new departure schedule must be created.

All n scheduled flights must now depart at different minutes between (k + 1)-th and (k + n)-th, inclusive. However, it's not mandatory for the flights to depart in the same order they were initially scheduled to do so — their order in the new schedule can be different. There is only one restriction: no flight is allowed to depart earlier than it was supposed to depart in the initial schedule.

Helen knows that each minute of delay of the i-th flight costs airport ci burles. Help her find the order for flights to depart in the new schedule that minimizes the total cost for the airport.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 300 000), here n is the number of flights, and k is the number of minutes in the beginning of the day that the flights did not depart.

The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 107), here ci is the cost of delaying the i-th flight for one minute.

Output

The first line must contain the minimum possible total cost of delaying the flights.

The second line must contain n different integers t1, t2, ..., tn (k + 1 ≤ ti ≤ k + n), here ti is the minute when the i-th flight must depart. If there are several optimal schedules, print any of them.

Example
input
5 2
4 2 1 10 2
output
20
3 6 7 4 5 
Note

Let us consider sample test. If Helen just moves all flights 2 minutes later preserving the order, the total cost of delaying the flights would be (3 - 1)·4 + (4 - 2)·2 + (5 - 3)·1 + (6 - 4)·10 + (7 - 5)·2 = 38 burles. 

However, the better schedule is shown in the sample answer, its cost is (3 - 1)·4 + (6 - 2)·2 + (7 - 3)·1 + (4 - 4)·10 + (5 - 5)·2 = 20 burles.


题意:

给你n个飞机,k。按出发顺序1-n给你每个飞机拖延1分钟所要给的分数。让你重新排列飞机的飞行表。

前1-k分钟不能起飞。求一个出发顺序,让总分数最少。


POINT:

贪心安排,先安排分数最多的。

安排的时候用链表来连接分钟。不然一个一个判断超时。


C. Planning
time limit per test1 second
memory limit per test512 megabytes
inputstandard input
outputstandard output
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.

Metropolis airport is the main transport hub of Metropolia, so it is difficult to keep the schedule intact. This is exactly the case today: because of technical issues, no flights were able to depart during the first k minutes of the day, so now the new departure schedule must be created.

All n scheduled flights must now depart at different minutes between (k + 1)-th and (k + n)-th, inclusive. However, it's not mandatory for the flights to depart in the same order they were initially scheduled to do so — their order in the new schedule can be different. There is only one restriction: no flight is allowed to depart earlier than it was supposed to depart in the initial schedule.

Helen knows that each minute of delay of the i-th flight costs airport ci burles. Help her find the order for flights to depart in the new schedule that minimizes the total cost for the airport.

Input
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 300 000), here n is the number of flights, and k is the number of minutes in the beginning of the day that the flights did not depart.

The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 107), here ci is the cost of delaying the i-th flight for one minute.

Output
The first line must contain the minimum possible total cost of delaying the flights.

The second line must contain n different integers t1, t2, ..., tn (k + 1 ≤ ti ≤ k + n), here ti is the minute when the i-th flight must depart. If there are several optimal schedules, print any of them.

Example
input
5 2
4 2 1 10 2
output
20
3 6 7 4 5 
Note
Let us consider sample test. If Helen just moves all flights 2 minutes later preserving the order, the total cost of delaying the flights would be (3 - 1)·4 + (4 - 2)·2 + (5 - 3)·1 + (6 - 4)·10 + (7 - 5)·2 = 38 burles.

However, the better schedule is shown in the sample answer, its cost is (3 - 1)·4 + (6 - 2)·2 + (7 - 3)·1 + (4 - 4)·10 + (5 - 5)·2 = 20 burles.


源码下载地址: https://pan.quark.cn/s/7a349ad53637 在地理信息系统(GIS)领域中,土地利用现状图被视为一种核心的数据可视化手段,其主要功能在于呈现特定区域的土地使用格局,涵盖农业、住宅、工业、绿地等多样化的土地利用类型。此类信息对于城市规划、环境分析、土地监管以及决策制定具有基础性作用。在编制土地利用现状图的过程中,符号库的构建与样式匹配环节是保障地图具备清晰度、精确性及视觉美感的核心步骤。所谓"样式匹配",是一种技术手段,旨在让用户能够将特定的符号或视觉样式与地图中的数据要素建立关联。在本资源中,提及的"样式匹配lyr"文件或许是一个ArcGIS(一种广受欢迎的GIS软件)所使用的图层样式文件,该文件内含了预设的图例符号及使用规范,用以区分不同的土地利用类别。用户若将此lyr文件导入至个人项目中,便能够迅速为土地利用现状图层赋予统一且专业的视觉表现。符号库则是指存储各类图形符号的集合,这些符号在地图上代表了不同的地理要素。对于土地利用现状图而言,每一类土地通常都会对应一个特定的符号,比如农田可能以绿色填充图案来表现,而建筑用地则可能采用灰色的实心形状。这些符号库对于统一地图的视觉呈现至关重要,有助于观者迅速把握地图所传递的信息。在ArcGIS软件中,用户能够通过"图层属性"界面来调控图层的视觉样式。在该界面中,用户可以选择"符号"面板来设定数据的可视化方式,或选择"标签"面板来管理要素的标注规则。借助"加载样式"功能,用户可以将"样式匹配lyr"文件中的样式规则应用到当前图层,以此规避逐一对每个土地利用类型进行符号的手动配置。不仅如此,为了达成卓越的可视化效果,可能还需对其他图层属性进行微调,例如调节透明度、设置比例尺依赖...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值