A - Coffee Break Gym - 101911A (优先队列)

Recently Monocarp got a job. His working day lasts exactly mm minutes. During work, Monocarp wants to drink coffee at certain moments: there are nn minutes a1,a2,…,ana1,a2,…,an, when he is able and willing to take a coffee break (for the sake of simplicity let's consider that each coffee break lasts exactly one minute).

However, Monocarp's boss doesn't like when Monocarp takes his coffee breaks too often. So for the given coffee break that is going to be on minute aiai, Monocarp must choose the day in which he will drink coffee during the said minute, so that every day at least dd minutes pass between any two coffee breaks. Monocarp also wants to take these nn coffee breaks in a minimum possible number of working days (he doesn't count days when he is not at work, and he doesn't take coffee breaks on such days). Take into account that more than dd minutes pass between the end of any working day and the start of the following working day.

For each of the nn given minutes determine the day, during which Monocarp should take a coffee break in this minute. You have to minimize the number of days spent.

Input

The first line contains three integers nn, mm, dd (1≤n≤2⋅105,n≤m≤109,1≤d≤m)(1≤n≤2⋅105,n≤m≤109,1≤d≤m) — the number of coffee breaks Monocarp wants to have, the length of each working day, and the minimum number of minutes between any two consecutive coffee breaks.

The second line contains nn distinct integers a1,a2,…,ana1,a2,…,an (1≤ai≤m)(1≤ai≤m), where aiai is some minute when Monocarp wants to have a coffee break.

Output

In the first line, write the minimum number of days required to make a coffee break in each of the nn given minutes.

In the second line, print nn space separated integers. The ii-th of integers should be the index of the day during which Monocarp should have a coffee break at minute aiai. Days are numbered from 11. If there are multiple optimal solutions, you may print any of them.

Examples

Input

4 5 3
3 5 1 2

Output

3
3 1 1 2 

Input

10 10 1
10 5 7 4 6 3 2 1 9 8

Output

2
2 1 1 2 2 1 2 1 1 2 

Note

In the first example, Monocarp can take two coffee breaks during the first day (during minutes 11 and 55, 33 minutes will pass between these breaks). One break during the second day (at minute 22), and one break during the third day (at minute 33).

In the second example, Monocarp can determine the day of the break as follows: if the minute when he wants to take a break is odd, then this break is on the first day, if it is even, then this break is on the second day.

题意:

Monocarp得到一份工作,每天要工作 m 分钟,他有一个爱好,喜欢在休息的时候喝咖啡,但是他的老板不乐意了,就给他规定了个时间 d,在 d 分钟内只能喝一杯咖啡。现给出Monocarp喝 n 杯咖啡的时间点,问最少需要几天喝完?并输出每个时间点的咖啡在第几天喝。


//Full of love and hope for life

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <map>
//https://paste.ubuntu.com/

using namespace std;

int main(){
     ios::sync_with_stdio(false);
     int m[200010],n[200010];
     priority_queue<int,vector<int>,greater<int> >q;
     map<int,int>ma;
     int a,b,c,k=1;
     cin >> a >> b >> c;
     memset(n,0,sizeof(n));
     for(int i=1;i<=a;i++){
        cin >> m[i];
        n[i]=m[i];
     }
     sort(n+1,n+a+1);
     q.push(1);
     ma[n[1]]=1;
     for(int i=2;i<=a;i++){
        int t=q.top();
        if(n[i]-n[t]>c){
            ma[n[i]]=ma[n[t]];
            q.pop();
        }
        else{
            k++;
            ma[n[i]]=k;
        }
        q.push(i);
     }
     cout << k << endl;
     for(int i=1;i<=a;i++){
        if(i==a){
            cout << ma[m[i]];
        }
        else{
            cout << ma[m[i]] << " ";
        }
     }
     return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
IoT是物联网(Internet of Things)的缩写,是指通过物理设备和传感器等技术将物理世界与互联网连接起来的概念。Sensor是传感器的意思,是一种能够感知和测量周围环境参数的装置。Gym master是指健身房的管理系统。那么,"IoT-Sensor-Gym-Master"指的是结合物联网、传感器技术和健身房管理系统的项目或产品。 在这个项目中,通过在健身房内部部署各种类型的传感器设备,可以实时感知和监控健身房的各种环境参数以及用户的行为。例如,可以使用体感传感器来监测用户的运动状态,心率传感器来监测用户心率变化,温湿度传感器来监测环境的温度和湿度等等。这些传感器会把收集到的数据通过物联网技术传输到云端服务器进行处理和分析。 在云端服务器上,会有一个健身房管理系统,通过对接收到的传感器数据进行分析和处理,可以提供各种健身相关的功能和服务。例如,可以根据用户的运动状态自动调整健身器材的强度,提供个性化的健身方案;还可以通过用户心率数据实时预警和监控用户的身体状况,保证用户的健康安全;同时,还可以通过温湿度传感器来实时监测健身房的环境,保证用户的舒适度。 总之,"IoT-Sensor-Gym-Master"项目结合了物联网、传感器技术和健身房管理系统的优势,将智能化和个性化服务引入健身领域,为用户提供更好的健身体验和管理服务。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZZ --瑞 hopeACMer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值