按照Di排序,从小到大枚举物品,考虑如果直接能选就选上,不能选就考虑替换之前价值最小的来选(显然一定是可行的,只需要在原来选价值最小的时候选这个就行了),这个东西用堆来维护即可 1 #include<bits/stdc++.h> 2 using namespace std; 3 struct ji{ 4 int d,p; 5 }a[100005]; 6 priority_queue<int>q; 7 int n,m,x,y,s; 8 long long ans; 9 bool cm
费用流模板题..限制一下不同愤怒值的工作数就可以了. --------------------------------------------------------------------------------------------- #include<queue> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long l