#GD0000072. Lập lịch chuyến bay (Planning)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lập lịch chuyến bay (Planning)
Planning
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are flights, originally scheduled at minutes through . Delaying flight by one minute costs . Due to an outage, no flight may depart during the first minutes. Assign each flight to a distinct minute in , never earlier than its original minute . Minimize total cost and output the new departure minute for every flight.
Input
The first line contains . The second line contains .
Output
Print the minimum total delay cost. On the next line, print exactly integers in original flight order. Any feasible minimum-cost schedule is accepted.
Subtasks
- Subtask 1 (20 points): ; ; for every ; departure times are distinct integers in with .
- Subtask 2 (30 points): ; ; for every ; departure times are distinct integers in with .
- Subtask 3 (50 points): ; ; for every ; departure times are distinct integers in with .
Examples
Input
5 2
4 2 1 10 2
Output
20
3 6 7 4 5
Explanation
Flights originally planned at minutes through must use minutes through . One optimal schedule is with cost . Any optimal valid schedule is accepted.