ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

[Usaco2006 Feb]Stall Reservations 专用牛棚

2021-06-03 18:06:06  阅读:261  来源: 互联网

标签:Feb .. cow Reservations Stall Output Input Line


Problem :

目录

Problem :

Description

Input

Output

Sample Input

Sample Output


 

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 149  Solved: 66
[Submit][Status][Web Board]

Description

Oh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over s
ome precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and B. Obviou
sly, FJ must create a reservation system to determine which stall each cow can be assigned for her m
ilking time. Of course, no cow will share such a private moment with other cows. Help FJ by determin
ing: * The minimum number of stalls required in the barn so that each cow can have her private milki
ng period * An assignment of cows to these stalls over time

有N头牛,每头牛有个喝水时间,这段时间它将专用一个Stall 现在给出每头牛的喝水时间段,问至少要多少个Stall
才能满足它们的要求

Input

* Line 1: A single integer, N
* Lines 2..N+1: Line i+1 describes cow i's milking interval with two space-separated integers.

Output

* Line 1: The minimum number of stalls the barn must have.
* Lines 2..N+1: Line i+1 describes the stall to which cow i will be assigned for her milking period.

Sample Input

5
1 10
2 4
3 6
5 8
4 7

Sample Output

4
//Here's a graphical schedule for this output:
Time 1 2 3 4 5 6 7 8 9 10
Stall 1 c1>>>>>>>>>>>>>>>>>>>>>>>>>>>
Stall 2 .. c2>>>>>> c4>>>>>>>>> .. ..
Stall 3 .. .. c3>>>>>>>>> .. .. .. ..
Stall 4 .. .. .. c5>>>>>>>>> .. .. ..
Other outputs using the same number of stalls are possible.

标签:Feb,..,cow,Reservations,Stall,Output,Input,Line
来源: https://blog.csdn.net/qq_36100991/article/details/74452217

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有