传送门
把任务按照d排序
一次加入到堆中,如果当前放不进堆中,并且比堆中最小的大,
就从堆中弹出一个数,再把当前的数放进去
#include <queue> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 100001 #define LL long long using namespace std; int n; LL ans; priority_queue <LL, vector <LL>, greater <LL> > q; struct node a[N]; inline LL read() inline bool cmp(node x, node y) int main() while(!q.empty()) ans += q.top(), q.pop(); printf("%lld\n", ans); return 0; }
上一篇:[POJ2443]Set Operation(bitset)
下一篇:[BZOJ1575] [Usaco2009 Jan]气象牛Baric(DP)
stl 堆 贪心









