CF187E.Heaven Tour

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The story was not finished as PMP thought. God offered him one more chance to reincarnate and come back to life. But before he can come back, God told him that PMP should ask nn great men including prominent programmers about their life experiences.

The men are standing on a straight line. They are numbered 11 through nn from left to right. The coordinate of the ii -th man is xix_{i} (x_{i}<x_{i+1},i<n) . PMP should visit all these people one by one in arbitrary order. Each men should be visited exactly once. At the beginning of his tour, he starts at location of ss -th man and asks him about his experiences.

Each time PMP wants to change his location, he should give a ticket to an angel and the angel carries him to his destination. Angels take PMP from one location, fly to his destination and put him down there. Nobody else is visited in this movement. Moving from ii -th man to jj -th man, takes xixj|x_{i}-x_{j}| time. PMP can get back to life as soon as he visits all men.

There are two types of angels: Some angels are going to the right and they only accept right tickets. Others are going the left and they only accept left tickets. There are an unlimited number of angels of each type. PMP has ll left tickets and n1ln-1-l right tickets.

PMP wants to get back to life as soon as possible to be able to compete in this year's final instead of the final he missed last year. He wants to know the quickest way to visit all the men exactly once. He also needs to know the exact sequence moves he should make.

输入格式

The first line of input contains three space-separated integers n,l,sn,l,s ( 2<=n<=10^{5},0<=l<n,1<=s<=n ) — the number of people to visit, the number left tickets PMP got, and initial location of PMP. Next line contains nn space-separated integers. The ii -th integer in this line is xix_{i} ( 0=x_{1}<x_{2}<...<x_{n}<=10^{9} ) — the location of ii -th man.

输出格式

If PMP cannot visit all men with the tickets he got print -1 in the only line of output. Otherwise, in the first line you should print the minimum time PMP can visit all men. In the second line you should print n1n-1 integers that are the numbers of the men that PMP should visit in order in one optimal solution. If there are multiple answers, output any of them.

Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specifier.

输入输出样例

  • 输入#1

    5 2 2
    0 10 11 21 22
    

    输出#1

    33
    1 3 5 4
    
  • 输入#2

    4 3 1
    0 1 2 3
    

    输出#2

    -1
    
  • 输入#3

    7 3 2
    0 100 200 201 301 303 305
    

    输出#3

    409
    1 3 4 7 6 5
    

说明/提示

Let us remind here, a great contestant of all times, who left us about a year ago. May Renat Mullakhanov rest in peace.

首页