QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#1173. 知識就是...

الإحصائيات

今天,Songjuk Haksa 預計將有 $N$ 個專案發布。Jongyoung 和他的朋友們不想做太多工作,因此他們決定分擔這些專案並進行實作。

專案 $i$ 可在時間 $L_i$ 存取,且必須在時間 $R_i$ 或之前完成。然而,學生的學習能力不是很好,因此處理一個專案會耗盡所有可用時間。

此外,學生無法同時處理多個專案,因此如果學生選擇了兩個專案 $i$ 和 $j$,則必須滿足 $R_i < L_j$ 或 $R_j < L_i$。同時,學生對繁重的工作興趣不高,因此每位學生最多只能處理兩個專案。

一組 $M$ 位優秀的學生想要共同實作盡可能多的專案。請協助他們決定每位學生需要負責哪些專案。如果有多種可能的方式,你可以選擇其中任何一種。

輸入格式

第一行包含兩個整數 $N$ 和 $M$,分別代表專案數量和學生數量 ($1 \le M \le N \le 3 \cdot 10^5$)。

接下來的 $N$ 行,每行包含兩個整數 $L_i$ 和 $R_i$:代表第 $i$ 個專案的開始時間與結束時間 ($1 \le L_i < R_i \le 10^9$)。

輸出格式

輸出 $N$ 個整數。第 $i$ 個整數必須是負責處理專案 $i$ 的學生編號(從 $1$ 到 $M$)。如果沒有學生處理專案 $i$,則輸出 $0$。

實作的專案數量必須達到最大值。如果有多種可能的解,請輸出其中任何一種。

範例

輸入 1

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

輸出 1

3 2 2 5 5 4 1

輸入 2

2 2
1 2
3 4

輸出 2

1 1

輸入 3

2 1
1 2
2 3

輸出 3

1 0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.