
#include <iostream>#include <cstdio>#include <queue>#include <cstring>using namespace std;struct Schedule{ int profit; int dt; bool operator<(const Schedule &rhs)const { return profit<rhs.profit; }};bool used[10001];priority_queue<Schedule> que;int main(){ int n; while(scanf("%d",&n)!=EOF){ while(!que.empty())que.pop(); int max = 0; for (int i=0;i<n;i++){ Schedule prod; scanf("%d %d",&prod.profit,&prod.dt); if (prod.dt>max) max = prod.dt; que.push(prod); } memset(used,false,sizeof(bool)*(max+1)); long long sum =0; int current = 0; while(!que.empty()){ Schedule prod = que.top(); que.pop(); while(prod.dt--){ if (!used[prod.dt]){ used[prod.dt] = true; sum+=prod.profit; break; } } } printf("%dn",sum); } return 0;}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)