Submission #1820499


Source Code Expand

#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	int N;
	cin >> N;

	int a[50];
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	int ans = -100000;
	for (int i = 0; i < N; i++)
	{
		int maxTak = -1000000;
		int maxAok = -1000000;
		int aokiIndex = 0;
		for (int j = 0; j < N; j++)
		{
			if (i == j)
			{
				continue;
			}

			int s = max(i, j);
			int t = min(i, j);

			int c = 0;
			int tak = 0;
			int aok = 0;

			for (; t <= s; t++)
			{
				c++;
				if (c % 2 == 1)
				{
					tak += a[t];
				}
				else {
					aok += a[t];
				}
			}

			if (aok > maxAok)
			{
				{
					//maxAok = max(aok, maxAok);
					maxAok = aok;
					maxTak = tak;
					//maxTak = max(tak, maxTak);
					//cout << maxTak << " " << maxAok << endl;
				}
			}
			ans = max(maxTak, ans);
		}

		cout << ans << endl;
		return 0;
	}

Submission Info

Submission Time
Task C - 数列ゲーム
User butanokakuni
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1118 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:74:2: error: expected ‘}’ at end of input
  }
  ^