国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

Murder in Restaurant

2019-11-10 18:28:32
字體:
供稿:網(wǎng)友

Murder in closet happened again in a small restaurant and Conan went there to collect evidence with Kogoro. After they reached the restaurant, they got a list of renters that lived in this restaurant recently. Yet the list was so long that they couldn't get the useful information from it. As an assistant of Conan, you must have been ready to help him to get the information on which rooms the renters have lived in.

Input

There are no more than 20 test cases. The first line of each test case contains two integers n and m, indicating the number of renters and the rooms of the restaurant (0 < nm <= 100). The i-th line of the next n lines contains two integers t1 and t2, the day when they wanted to check in and to leave (0 < t1 < t2 <= 1000).

Each renter rends exactly one room and their check-in days are distinct. Each time a renter came, the owner would give him/her an available room with minimum room number if there were still empty rooms. Otherwise the renter would leave at once and never come back again. Note that rooms are always returned in morning and rented in afternoon. The input is ended with two zeroes.

Output

For each test case, output n lines of integers. The i-th integer indicates the room number of the i-th renter. The rooms are numbered from 1. If someone didn't live in this restaurant, output 0 in the corresponding line.

Sample Input

2 51 32 44 21 52 33 54 50 0

Sample Output

12122

0

題目大意:

第一行給出兩個數(shù)字n,m

n代表房客個數(shù)m代表房間數(shù)

主人給房客安排房間從1開始到m

下面n行代表n個房客的需求 入住時間和不住的時間

我們需要輸出每一個房客的入住的房間號

如果沒有房間住就輸出0

代碼

#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<ctype.h>#include<stack>#include<queue>using namespace std;struct nana{    int i,o,r,n;}a[10003];int cmp1(nana a,nana b){    if(a.i==b.i)        return a.o<b.o;    return a.i<b.i;}int cmp2(nana a,nana b){    return a.n<b.n;}int main(){    int n,m;    int r[1003];    while(scanf("%d%d",&n,&m)==2&&n)    {        for(int i=0;i<1003;i++)r[i]=0;        for(int i=1;i<=n;i++)        {           scanf("%d%d",&a[i].i,&a[i].o);           a[i].n=i;        }        sort(a+1,a+n+1,cmp1);        for(int i=1;i<=n;i++)        {            int flag=0;            for(int j=1;j<=m;j++)            {                if(a[i].i>=r[j])                {                    a[i].r=j;                    r[j]=a[i].o;                    flag=1;                    break;                }            }            if(!flag)                a[i].r=0;        }        sort(a+1,a+n+1,cmp2);        for(int i=1;i<=n;i++)        {            PRintf("%d/n",a[i].r);        }    }}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 玛沁县| 任丘市| 桑植县| 铜山县| 太原市| 娱乐| 洪雅县| 永吉县| 桦甸市| 石河子市| 芷江| 甘肃省| 洮南市| 苗栗县| 巧家县| 牡丹江市| 丽江市| 大英县| 金湖县| 云南省| 康定县| 大理市| 咸阳市| 普定县| 阜城县| 思南县| 尉犁县| 曲松县| 思茅市| 尼木县| 溧阳市| 清水河县| 潞西市| 沙田区| 普安县| 乐至县| 花垣县| 铅山县| 花垣县| 错那县| 阿合奇县|