Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,b,p,f,h,c,d,e;
- cin>>n;
- while(n--)
- {
- cin>>b>>p>>f;
- cin>>h>>c;
- d=(p*2)+(f*2);
- if(b>=d)
- cout<<(p*h)+(f*c)<<endl;
- else{
- e=b/2;
- if(h>c){
- if(p<=e && f<=(e-p))
- cout<<(p*h)+((f*c))<<endl;
- else if (p<=e && f>(e-p))
- cout<<(p*h)+((e-p)*c);
- else if(p>e)
- cout<<(p*h)<<endl;
- }
- else if(c>h){
- if(f<=e && p<=(e-f))
- cout<<(p*h)+((f*c))<<endl;
- else if (f<=e && p>(e-f))
- cout<<((e-f)*h)+(f*c);
- else if(f>e)
- cout<<(f*c)<<endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement