题目链接
思路:
枚举每一种情况找出剩余质量最少的情况即放入的最多的情况即可。
代码:
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=1e5+7;
const int M=1e4+5;
const double eps=1e-8;
const int mod=1e9+7;
const int inf=0x7fffffff;
const double pi=3.1415926;
using namespace std;
signed main()
{
int t;
cin>>t;
while(t--)
{
int p,f,cnts,cntw,s,w;
cin>>p>>f>>cnts>>cntw>>s>>w;
if(s>w)
{
swap(s,w);
swap(cnts,cntw);
}
int ans=0;
for(int s1=0;s1*s<=p && s1<=cnts;s1++)
{
int w1=(p-s1*s)/w;
int s2=min(cnts-s1,f/s);
int w2=min((f-s2*s)/w,cntw-w1);
ans=max(ans,s1+s2+w1+w2);
}
cout<<ans<<endl;
}
return 0;
}