Skip to content

Instantly share code, notes, and snippets.

@yuuki
Created May 24, 2012 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuki/2784948 to your computer and use it in GitHub Desktop.
Save yuuki/2784948 to your computer and use it in GitHub Desktop.
SRM Div2-146 250score
// {{{ Boilerplate Code <--------------------------------------------------
//
// vim:filetype=cpp foldmethod=marker foldmarker={{{,}}}
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N) FOR(I,0,N)
#define ALL(A) (A).begin(), (A).end()
using namespace std;
// }}}
class YahtzeeScore
{
public:
int maxPoints(vector <int> toss)
{
vector<int> v(6);
for (vector<int>::iterator i = toss.begin(); i != toss.end(); ++i) {
v[*i - 1] += *i;
}
return *max_element(v.begin(), v.end());
}
};
int main() {
int s[5] = { 6, 4, 1, 1, 3 };
vector<int> v;
v.assign(s, s + 5);
YahtzeeScore score;
cout << score.maxPoints(v) << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment