有 R 个红色盒子和 B 个蓝色盒子,还有 R 个红色小球和 B 个蓝色小球。每个盒子只能装一个小球,每个小球都要放在一个盒子里。如果把一个红色小球放在一个红色盒子里,那么得分是 C。如果把一个蓝色小球放在一个蓝色盒子里,那么得分是 D。如果把一个红色小球放在一个蓝色盒子里,那么得分是 E。如果把一个蓝色小球放在一个红色盒子里,那么得分也是 E。现在给出 R,B,C,D,E。应该如何放置这些小球进盒子,才能使得总得分最大?输出最大的总得分。

#include<bits/stdc++.h>
using namespace std;
int r,b,c,d,e;
int main(){
	cin>>r>>b>>c>>d>>e;
	if(c<=e){
		if(d<=e){
			cout<<e*(r+b);
			return 0;
		}
		if(d>e){
			cout<<e*c+d*b;
			return 0;
		}
	}
	if(c>e){
		if(d>e){
			cout<<c*r+d*b;
			return 0;
		}
		if(d<e){
			cout<<r*c+e*d;
			return 0;
		}
	}
	return 0;
}//2 3 100 400 200为什么答案是21200,求解

0 comments

No comments so far...

Information

ID
6740
Time
1000ms
Memory
256MiB
Difficulty
1
Tags
# Submissions
3
Accepted
2
Uploaded By