题目链接:点击打开链接
题意:
给定n个箱子m个物品
下面n个数字表示箱子的容量
下面m个数字b1-bm 表示物品体积为2^bi大
问最多有多少个物品可以放入箱子。
思路:
贪心,先放小的,小的不能放再放大的
显然我们把n个箱子拆成二进制,然后模拟二进制减法运算。
剩下就是简单模拟
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>
#include<map>
#include<vector>
using namespace std;
#define ll __int64
#define N 50
ll n,_gcd,m,k;
ll a[N],b[N],er[N];
bool jie(ll pos, ll ge){
bool hav = false;
ll now;
for(ll i = pos+1; i < N; i++)
if(a[i]){
hav = true;
now = i;
break;
}
if(hav==false)return false;
ll ned = ge / er[now-pos];
if(ned==0){
a[now]--;
a[pos]&#