結果

問題 No.999 てん vs. ほむ
ユーザー t98slidert98slider
提出日時 2022-12-23 15:34:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 165,928 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2023-08-11 11:52:16
合計ジャッジ時間 5,891 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 74 ms
7,376 KB
testcase_10 AC 23 ms
4,448 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 34 ms
4,900 KB
testcase_13 AC 81 ms
7,748 KB
testcase_14 AC 80 ms
7,732 KB
testcase_15 AC 80 ms
7,884 KB
testcase_16 AC 81 ms
8,064 KB
testcase_17 AC 54 ms
7,252 KB
testcase_18 AC 53 ms
7,256 KB
testcase_19 AC 53 ms
7,372 KB
testcase_20 AC 53 ms
7,304 KB
testcase_21 AC 79 ms
7,540 KB
testcase_22 AC 77 ms
7,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  n *= 2;
  ll ans = -(1ll << 60);
  vector<ll> a(n), s0(n + 1), s1(n + 1);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    s0[i + 1] = s0[i] + (i & 1 ? -a[i] : a[i]);
    s1[i + 1] = s1[i] + (i & 1 ? a[i] : -a[i]);
  }
  for(int i = 0; i <= n; i += 2){
    ans = max(ans, s0[i] + s1[n] - s1[i]);
  }
  cout << ans << '\n';
}
0