#abc325d. D - Printing Machine
D - Printing Machine
Score : points
问题描述
有个产品在传送带上流动,编号为1到。传送带上连接了一台基恩士打印机,第个产品将在微秒后进入打印机的打印范围,并在微秒后离开该范围。
基恩士打印机能够在打印范围内立即对一个产品进行打印(特别是,当产品进入或离开打印范围时可以立即打印)。但是,在完成一次打印后,需要充电时间为微秒才能再次进行打印。当选择最优的产品和打印时机时,打印机最多能打印多少个产品?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are products labeled to flowing on a conveyor belt. A Keyence printer is attached to the conveyor belt, and product enters the range of the printer microseconds from now and leaves it microseconds later.
The Keyence printer can instantly print on one product within the range of the printer (in particular, it is possible to print at the moment the product enters or leaves the range of the printer). However, after printing once, it requires a charge time of microseconds before it can print again. What is the maximum number of products the printer can print on when the product and timing for the printer to print are chosen optimally?
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the maximum number of products the printer can print on.
Sample Input 1
5
1 1
1 1
2 1
1 2
1 4
Sample Output 1
4
Below, we will simply call the moment microseconds from now time .
For example, you can print on four products as follows:
- Time : Products enter the range of the printer. Print on product .
- Time : Product enters the range of the printer, and products leave the range of the printer. Print on product .
- Time : Products leave the range of the printer. Print on product .
- Time : Print on product .
- Time : Product leaves the range of the printer.
It is impossible to print on all five products, so the answer is .
Sample Input 2
2
1 1
1000000000000000000 1000000000000000000
Sample Output 2
2
Sample Input 3
10
4 1
1 2
1 4
3 2
5 1
5 1
4 1
2 1
4 1
2 4
Sample Output 3
6
update @ 2024/3/10 01:48:04