java:
不快乐打卡困难每日一题
贪心和优先队列 谢谢题解 谢谢大佬给我讲
class Solution {
public int scheduleCourse(int[][] courses) {
Arrays.sort(courses,(a,b)->a[1]-b[1]);
PriorityQueue<Integer> q = new PriorityQueue<>((a,b)->b-a);
int sum = 0;
for(int[] c : courses){
int d = c[0], e = c[1];
sum += d;
q.add(d);
if(sum > e)
sum -= q.poll();
}
return q.size();
}
}