CF1256E.Yet Another Division Into Teams

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There are nn students at your university. The programming skill of the ii -th student is aia_i . As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has 21052 \cdot 10^5 students ready for the finals!

Each team should consist of at least three students. Each student should belong to exactly one team. The diversity of a team is the difference between the maximum programming skill of some student that belongs to this team and the minimum programming skill of some student that belongs to this team (in other words, if the team consists of kk students with programming skills a[i1],a[i2],,a[ik]a[i_1], a[i_2], \dots, a[i_k] , then the diversity of this team is maxj=1ka[ij]minj=1ka[ij]\max\limits_{j=1}^{k} a[i_j] - \min\limits_{j=1}^{k} a[i_j] ).

The total diversity is the sum of diversities of all teams formed.

Your task is to minimize the total diversity of the division of students and find the optimal way to divide the students.

输入格式

The first line of the input contains one integer nn ( 3n21053 \le n \le 2 \cdot 10^5 ) — the number of students.

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ai1091 \le a_i \le 10^9 ), where aia_i is the programming skill of the ii -th student.

输出格式

In the first line print two integers resres and kk — the minimum total diversity of the division of students and the number of teams in your division, correspondingly.

In the second line print nn integers t1,t2,,tnt_1, t_2, \dots, t_n ( 1tik1 \le t_i \le k ), where tit_i is the number of team to which the ii -th student belong.

If there are multiple answers, you can print any. Note that you don't need to minimize the number of teams. Each team should consist of at least three students.

输入输出样例

  • 输入#1

    5
    1 1 3 4 2
    

    输出#1

    3 1
    1 1 1 1 1 
    
  • 输入#2

    6
    1 5 12 13 2 15
    

    输出#2

    7 2
    2 2 1 1 2 1 
    
  • 输入#3

    10
    1 2 5 129 185 581 1041 1909 1580 8150
    

    输出#3

    7486 3
    3 3 3 2 2 2 2 1 1 1 
    

说明/提示

In the first example, there is only one team with skills [1,1,2,3,4][1, 1, 2, 3, 4] so the answer is 33 . It can be shown that you cannot achieve a better answer.

In the second example, there are two teams with skills [1,2,5][1, 2, 5] and [12,13,15][12, 13, 15] so the answer is 4+3=74 + 3 = 7 .

In the third example, there are three teams with skills [1,2,5][1, 2, 5] , [129,185,581,1041][129, 185, 581, 1041] and [1580,1909,8150][1580, 1909, 8150] so the answer is 4+912+6570=74864 + 912 + 6570 = 7486 .

首页