Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int t,n,bun,patt,chic,price_h,price_c,can_m,have_m,profit,sell_h,sell_c;
- scanf("%d",&t);
- for(n=0;n<t && t>=1 && t<=100;n++){
- scanf("%d %d %d",&bun,&patt,&chic);
- scanf("%d %d",&price_h,&price_c);
- if((price_h>=1) && (price_h<=100) && (price_c>=1) && (price_c<=100) && (bun>=1) && (bun<=100) && (patt>=1) && (patt<=100) && (chic>=1) && (chic<=100))
- {
- if(bun%2!=0){
- can_m=(bun-1)/2;
- }
- else if(bun%2==0){
- can_m=bun/2;
- }
- have_m=patt+chic;
- if(bun==1 || bun==0){
- printf("0\n");
- }
- else if(can_m>=have_m){
- profit=(patt*price_h)+(chic*price_c);
- printf("%d\n",profit);
- }
- else if(can_m<have_m){ // solving
- if(price_h<price_c){
- if(can_m>chic){
- sell_h=can_m-chic;
- sell_c=can_m-sell_h;
- profit=(sell_h*price_h)+(sell_c*price_c);
- printf("%d\n",profit);
- }
- else if(can_m<=chic){
- sell_c=can_m;
- profit=sell_c*price_c;
- printf("%d\n",profit);
- }
- }
- else if(price_h>price_c){
- if(can_m>patt){
- sell_c=can_m-patt;
- sell_h=can_m-sell_c;
- profit=(sell_h*price_h)+(sell_c*price_c);
- printf("%d\n",profit);
- }
- else if(can_m<=patt){ //
- sell_h=can_m;
- profit=sell_h*price_h;
- printf("%d\n",profit);
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement