标签:break turn amp love highlight over lse algo using
贪心,尽量捡便宜的买,反正是糊弄更多的老百姓开心。
// q.c
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef unsigned long long ULL;
const int M=100000+10;
struct Flower {
ULL cost,lover;
bool operator < (const Flower &A) const {
if(cost!=A.cost) return cost<A.cost;
else return lover>A.lover;
}
}flower[M];
int n; ULL b,ans;
int main() {
freopen("haoi13_t2.in","r",stdin);
freopen("haoi13_t2.out","w",stdout);
cin>>n>>b;
for(int i=1;i<=n;i++) cin>>flower[i].cost>>flower[i].lover;
sort(flower+1,flower+n+1);
for(int i=1;i<=n;i++) {
ULL cnt=b/flower[i].cost;
if(!cnt) break;
if(cnt>flower[i].lover) cnt=flower[i].lover;
b-=flower[i].cost*cnt;
ans+=cnt;
}
cout<<ans;
return 0;
}
标签:break turn amp love highlight over lse algo using
原文地址:https://www.cnblogs.com/qjs12/p/8848689.html