SRM 212 Div II Level One: YahtzeeScore

题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=1692&rd=5858


比较简单。

代码如下:

 

#include <iostream>
#include <vector>

using namespace std;

class YahtzeeScore
{
public:
	int maxPoints(vector <int> toss);
};

int YahtzeeScore::maxPoints(vector<int> toss)
{
	int i, j;
	int size = toss.size();
	int maxP = 0;
	int sum;

	for (i = 0; i < size; i++) {
		sum = 0;
		for (j = 0; j < size; j++) {
			if (toss[i] == toss[j]) {
				sum += toss[i];
			}
		}
		if (sum > maxP) {
			maxP = sum;
		}
	}
	return maxP;
}


 

 

你可能感兴趣的:(level)