【算法】贪心
#include#include #include #include using namespace std;const int maxn=50010;struct cyc{ int num,value;}b[maxn];int n,m,a[maxn];long long ans=0;priority_queue ,greater >q;bool cmp(cyc a,cyc b){ return a.num =1;i--) { for(int j=now-1;j>=1;j--) { if(b[j].num>=a[i]){now=j;q.push(b[j].value);} else break; } if(q.empty()){ok=0;break;} ans+=q.top(); q.pop(); } if(!ok)printf("No Solution"); else printf("%lld",ans); return 0;}