Submission #1840772
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
//typedef vector <char> vc;
typedef list<ll> lst;
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;
#define Endl endl
/*--------------------template--------------------*/
vi vc;
typedef pair<ll, ll> P;
P calc()
{
P p;
p.first = 0;
p.second = 0;
REP(i, vc.size())
{
if (i % 2 == 0)
{
p.first += vc[i];
}
else
{
p.second += vc[i];
}
}
return p;
}
int main()
{
cin >> n;
vi v(n), vans;
vp vpp;
REP(i, n)
{
cin >> v[i];
}
REP(i, n)
{
for (int j = 0; j < i; j++)
{
for (int l = j; l < i; l++)
{
vc.push_back(v[l]);
}
vc.push_back(v[i]);
P p = calc();
vpp.push_back(p);
vc.clear();
}
vc.clear();
for (int j = i + 1; j < n; j++)
{
vc.push_back(v[i]);
for (int l = i + 1; l <= j; l++)
{
vc.push_back(v[l]);
}
P p = calc();
vpp.push_back(p);
vc.clear();
}
vc.clear();
REP(i, vpp.size())
{
if (sum < vpp[i].second)
{
sum = vpp[i].second;
ans = vpp[i].first;
}
}
vans.push_back(ans);
sum = 0;
ans = 0;
vpp.clear();
}
sort(ALL(vans));
cout << vans.back() << endl;
}
Submission Info
Submission Time |
|
Task |
C - 数列ゲーム |
User |
tettchan |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2124 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample-01.txt, sample-02.txt, sample-03.txt |
All |
sample-01.txt, sample-02.txt, sample-03.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt |
Case Name |
Status |
Exec Time |
Memory |
sample-01.txt |
AC |
1 ms |
256 KB |
sample-02.txt |
AC |
1 ms |
256 KB |
sample-03.txt |
AC |
1 ms |
256 KB |
test-01.txt |
AC |
1 ms |
256 KB |
test-02.txt |
AC |
1 ms |
256 KB |
test-03.txt |
WA |
1 ms |
256 KB |
test-04.txt |
AC |
1 ms |
256 KB |
test-05.txt |
AC |
1 ms |
256 KB |
test-06.txt |
WA |
1 ms |
256 KB |
test-07.txt |
AC |
1 ms |
256 KB |
test-08.txt |
AC |
1 ms |
256 KB |
test-09.txt |
AC |
1 ms |
256 KB |
test-10.txt |
WA |
1 ms |
256 KB |
test-11.txt |
AC |
1 ms |
256 KB |
test-12.txt |
AC |
1 ms |
256 KB |
test-13.txt |
AC |
1 ms |
256 KB |
test-14.txt |
AC |
1 ms |
256 KB |
test-15.txt |
AC |
1 ms |
256 KB |
test-16.txt |
WA |
1 ms |
256 KB |
test-17.txt |
AC |
1 ms |
256 KB |
test-18.txt |
AC |
1 ms |
256 KB |
test-19.txt |
AC |
1 ms |
256 KB |
test-20.txt |
WA |
1 ms |
256 KB |