传送门
这个题类似于建筑抢修。
先按照时间排序。
如果当前时间小于任务截止时间就选,
否则,看看当前任务价值是否比已选的任务的最小价值大,
如果是,就替换。
可以用优先队列。
——代码
1 #include <queue> 2 #include <cstdio> 3 #include <iostream> 4 #include <algorithm> 5 #define LL long long 6 7 const int MAXN = 1e6 + 5; 8 int n; 9 LL tim, ans; 10 struct node 11 p[MAXN]; 14 std::priority_queue <LL, std::vector <LL>, std::greater <LL> > q; 15 16 inline LL read() 17 24 25 inline bool cmp(node x, node y) 26 29 30 int main() 31 45 } 46 printf("%lld\n", ans); 47 return 0; 48 }View Code