P1208 [USACO1.3]混合牛奶 Mixing Milk

#include 
using namespace std;
struct Node{
	int price;
	int num;
};
bool cmp(Node a,Node b){
	return a.price>n>>m;vector ppp;ppp.resize(n);
	for(int i=0;i>ppp[i].price>>ppp[i].num;
	}
	sort(ppp.begin(),ppp.end(),cmp);
	int ans=n;int cost=0;
	for(int i=0;i0){
			ans-=ppp[i].num;
			cost+=ppp[i].num*ppp[i].price;
		}else{
			cost+=ans*ppp[i].price;
			ans=0;break;
		}
	}
	cout<

 

你可能感兴趣的:(C++/PAT/洛谷OJ)