mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>你有一台电脑,它可以 <strong>同时</strong> 运行无数个任务。给你一个二维整数数组 <code>tasks</code> ,其中 <code>tasks[i] = [start<sub>i</sub>, end<sub>i</sub>, duration<sub>i</sub>]</code> 表示第 <code>i</code> 个任务需要在 <strong>闭区间</strong> 时间段 <code>[start<sub>i</sub>, end<sub>i</sub>]</code> 内运行 <code>duration<sub>i</sub></code> 个整数时间点(但不需要连续)。</p>
 | 
						||
 | 
						||
<p>当电脑需要运行任务时,你可以打开电脑,如果空闲时,你可以将电脑关闭。</p>
 | 
						||
 | 
						||
<p>请你返回完成所有任务的情况下,电脑最少需要运行多少秒。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre><b>输入:</b>tasks = [[2,3,1],[4,5,1],[1,5,2]]
 | 
						||
<b>输出:</b>2
 | 
						||
<b>解释:</b>
 | 
						||
- 第一个任务在闭区间 [2, 2] 运行。
 | 
						||
- 第二个任务在闭区间 [5, 5] 运行。
 | 
						||
- 第三个任务在闭区间 [2, 2] 和 [5, 5] 运行。
 | 
						||
电脑总共运行 2 个整数时间点。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre><b>输入:</b>tasks = [[1,3,2],[2,5,3],[5,6,2]]
 | 
						||
<b>输出:</b>4
 | 
						||
<b>解释:</b>
 | 
						||
- 第一个任务在闭区间 [2, 3] 运行
 | 
						||
- 第二个任务在闭区间 [2, 3] 和 [5, 5] 运行。
 | 
						||
- 第三个任务在闭区间 [5, 6] 运行。
 | 
						||
电脑总共运行 4 个整数时间点。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= tasks.length <= 2000</code></li>
 | 
						||
	<li><code>tasks[i].length == 3</code></li>
 | 
						||
	<li><code>1 <= start<sub>i</sub>, end<sub>i</sub> <= 2000</code></li>
 | 
						||
	<li><code>1 <= duration<sub>i</sub> <= end<sub>i</sub> - start<sub>i</sub> + 1 </code></li>
 | 
						||
</ul>
 |