夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

アルゴリズムの勉強は・・・

ココでやろう!!!…って言ってみる。

でね。なんかね、今日見てたビデオで…

「SRM464 Div.2 Easyは比較的簡単だと思うので解いてみましょう。」

ってChokudaiさんがいったから解いてみようとしたわけよ・・・


でもこんなコード書いてあ〜れ?あと何分岐すればいいかな(;´Д`)

みたいになって挫折した。

// BEGIN CUT HERE
// PROBLEM STATEMENT
// You are playing a game where you have numRed red boxes, 
// numBlue blue boxes, 
// numRed red balls, and numBlue blue balls. 
// You must place a single ball into each box. 
// Each box is then scored as follows: 
// 
// 	If the box is red and it contains a red ball, you get 
// onlyRed points. 
// 	If the box is blue and it contains a blue ball, you get 
// onlyBlue points. 
// 	In all other cases, you get bothColors points. 
// 
// Your total score is the sum of the scores of all the boxes. 
// Return the maximum possible total score you can get. 
// 
// 
// DEFINITION
// Class:ColorfulBoxesAndBalls
// Method:getMaximum
// Parameters:int, int, int, int, int
// Returns:int
// Method signature:int getMaximum(int numRed, int numBlue, 
// int onlyRed, int onlyBlue, int bothColors)
// 
// 
// CONSTRAINTS
// -numRed and numBlue will each be between 1 and 100, 
// inclusive. 
// -onlyRed, onlyBlue, and bothColors will each be between 
// -1000 and 1000, inclusive. 
// 
// 
// EXAMPLES
// 
// 0)
// 2
// 3
// 100
// 400
// 200
// 
// Returns: 1400
// 
// 
// In this example, you should put two red balls into red 
// boxes, and three blue balls into blue boxes. 
// Then you can get 100 * 2 + 400 * 3 = 1400 points in total. 
// 
// 
// 1)
// 2
// 3
// 100
// 400
// 300
// 
// Returns: 1600
// 
// 
// bothColors is a larger value here than it was in the 
// previous example. 
// You should put two blue balls into red boxes, and two red 
// balls and one blue ball into blue boxes. 
// Then you can get 300 * 4 + 400 * 1 = 1600 points. 
// 
// 
// 2)
// 5
// 5
// 464
// 464
// 464
// 
// Returns: 4640
// 
// No matter how you place the balls, your score will always 
// be the same. 
// 
// 
// 3)
// 1
// 4
// 20
// -30
// -10
// 
// Returns: -100
// 
// The maximum total score may be less than zero. 
// 
// 
// 4)
// 9
// 1
// -1
// -10
// 4
// 
// Returns: 0
// 
// 
// 
// END CUT HERE
import java.util.*;
public class ColorfulBoxesAndBalls {
	public int getMaximum(int numRed, int numBlue, int onlyRed, int onlyBlue, int bothColors) {
		int score = 0;
		if (Math.max(onlyRed, onlyBlue) <= bothColors) {
			if (numRed <= numBlue) {
				score += numRed*bothColors + numBlue*onlyBlue;
			} else {
				score += numBlue*bothColors + numRed*onlyRed;
			}
		} else {
			score += numBlue*onlyBlue + numRed*onlyRed;
		}
		return score;
	}

	// BEGIN CUT HERE
	public static void main(String[] args) {
		ColorfulBoxesAndBalls temp = new ColorfulBoxesAndBalls();
		System.out.println(temp.getMaximum(int numRed, int numBlue, int onlyRed, int onlyBlue, int bothColors));
	}
	// END CUT HERE
}

なんで挫折するかねぇwww

まぁそれよりもJavaのお勉強したいんだわな。

そして?

ただいま参加中のMMは現在スコア計算で止まっております。



ってか肝心のクロスワード生成が分からぬw


まぁコードさらすのはとりあえず終わってからということで。


ではノシ