https://codeforces.com/contest/1207
A、There Are Two Types Of Burgers
数据规模不大,暴力即可
1 #include<iostream> 2 #include<sstream> 3 #include<fstream> 4 #include<algorithm> 5 #include<cstring> 6 #include<iomanip> 7 #include<cstdlib> 8 #include<cctype> 9 #include<vector> 10 #include<string> 11 #include<cmath> 12 #include<ctime> 13 #include<stack> 14 #include<queue> 15 #include<map> 16 #include<set> 17 #define mem(a,b) memset(a,b,sizeof(a)) 18 #define random(a,b) (rand()%(b-a+1)+a) 19 #define ll long long 20 #define ull unsigned long long 21 #define e 2.71828182 22 #define Pi acos(-1.0) 23 #define ls(rt) (rt<<1) 24 #define rs(rt) (rt<<1|1) 25 #define lowbit(x) (x&(-x)) 26 using namespace std; 27 int read() 28 { 29 int s=1,x=0; 30 char ch=getchar(); 31 while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();} 32 while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();} 33 return x*s; 34 } 35 int b,p,f,h,c; 36 void solve() 37 { 38 int res=-1; 39 for(int i=0;i<=min(p,b>>1);++i) 40 { 41 int j=min(f,(b-i*2)>>1); 42 res=max(res,h*i+c*j); 43 } 44 cout<<res<<endl; 45 } 46 int main() 47 { 48 int test=read(); 49 while(test--) 50 { 51 b=read(),p=read(),f=read(),h=read(),c=read(); 52 solve(); 53 } 54 }