using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] European ={0,32,15,19,4,21,2,25,17,34,6,27,13,
36,11,30,8,23,10,5,24,16,33,1,20,14,
31,9,22,18,29,7,28,12,35,3,26};
int[] American ={0,28,9,26,30,11,7,20,32,17,5,22,34,
15,3,24,36,13,1,0,27,10,25,29,12,8,
19,31,18,6,21,33,16,4,23,35,14,2};
int AnswerCnt = 0;
for (int LoopN = 2; LoopN <= 36; LoopN++) {
int MaxEuropean = DeriveMaxSum(European, LoopN);
int MaxAmerican = DeriveMaxSum(American, LoopN);
if (MaxEuropean < MaxAmerican) {
AnswerCnt++;
Console.WriteLine("N={0}のとき、ヨーロピアンでの最大={1}。アメリカンでの最大={2}",
LoopN, MaxEuropean, MaxAmerican);
}
}
Console.WriteLine("答えは{0}", AnswerCnt);
}
//配列と連続した要素数を引数として、和の最大値を返す
static int DeriveMaxSum(int[] pArr, int pN)
{
var SumSet = new HashSet<int>();
int UB = pArr.GetUpperBound(0);
for (int I = 0; I <= UB; I++) {
int wkSum = 0;
for (int J = I; J <= I + pN - 1; J++) {
int CurrInd = J;
if (UB < CurrInd) CurrInd -= UB + 1;
wkSum += pArr[CurrInd];
}
SumSet.Add(wkSum);
}
return SumSet.Max();
}
}