結果
問題 | No.999 てん vs. ほむ |
ユーザー | tsutaj |
提出日時 | 2020-02-19 17:33:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 542 bytes |
コンパイル時間 | 624 ms |
コンパイル使用メモリ | 51,816 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-10-08 07:29:18 |
合計ジャッジ時間 | 2,560 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <vector> #include <cstdio> #include <algorithm> using namespace std; using ll = long long int; const ll LONGINF = 1LL << 60; int main() { int N; scanf("%d", &N); N <<= 1; vector<ll> A(N), L(N+1), R(N+1); for(int i=0; i<N; i++) { scanf("%lld", &A[i]); L[i+1] = L[i] + (i % 2 ? -A[i] : A[i]); R[i+1] = R[i] + (i % 2 ? A[i] : -A[i]); } ll ans = -LONGINF; for(int i=0; i<=N; i+=2) { ans = max(ans, L[i] + (R[N] - R[i])); } printf("%lld\n", ans); return 0; }