ソースコード 拡げる

Copy
```#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< int,int > P;
typedef pair< ll,ll >Pll;
const int mod = 1e9+7;
const int inf = numeric_limits< int >::max()/3;

int sum[2][60] = {};
int a[60];

int main(void){
int n;
cin >> n;
for(int i = 1;i <= n;++i){
cin >> a[i];
sum[1][i] = sum[1][i-1];
sum[0][i] = sum[0][i-1];
if(i % 2 == 0){
sum[0][i] += a[i];
}else{
sum[1][i] += a[i];
}
}
int res = -inf;
for(int i = 1;i <= n;++i){
int m = -inf,cres;
for(int j = 1;j <= n;++j){
if(i == j){
continue;
}
int s = min(i,j),t = max(i,j);
if(s % 2 == 0){
if(sum[1][t] - sum[1][s-1] > m){
m = sum[1][t] - sum[1][s-1];
cres = sum[0][t] - sum[0][s-1];
}
}else{
if(sum[0][t] - sum[0][s-1] > m){
m = sum[0][t] - sum[0][s-1];
cres = sum[1][t] - sum[1][s-1];
}
}
}
res = max(res,cres);
}
cout << res << endl;
return 0;
}
```

#### 提出情報

提出日時 2015-11-21 21:25:59+0900 C - 数列ゲーム Ashurnasirpal C++ (GCC 4.9.2) 100 1004 Byte AC 26 ms 928 KB

#### ジャッジ結果

セット名 Sample All

 AC × 3
 AC × 20
セット名 テストケース
Sample sample-01.txt, sample-02.txt, sample-03.txt
All 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
ケース名 結果 実行時間 メモリ
sample-01.txt AC 26 ms 672 KB
sample-02.txt AC 26 ms 920 KB
sample-03.txt AC 26 ms 800 KB
test-01.txt AC 26 ms 684 KB
test-02.txt AC 23 ms 800 KB
test-03.txt AC 25 ms 732 KB
test-04.txt AC 23 ms 800 KB
test-05.txt AC 24 ms 672 KB
test-06.txt AC 26 ms 704 KB
test-07.txt AC 23 ms 800 KB
test-08.txt AC 26 ms 928 KB
test-09.txt AC 23 ms 796 KB
test-10.txt AC 26 ms 928 KB
test-11.txt AC 26 ms 928 KB
test-12.txt AC 23 ms 920 KB
test-13.txt AC 23 ms 928 KB
test-14.txt AC 25 ms 732 KB
test-15.txt AC 23 ms 676 KB
test-16.txt AC 23 ms 920 KB
test-17.txt AC 23 ms 712 KB
test-18.txt AC 23 ms 796 KB
test-19.txt AC 26 ms 676 KB
test-20.txt AC 23 ms 672 KB