結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
![]() |
提出日時 | 2020-02-28 21:29:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 1,013 bytes |
コンパイル時間 | 1,842 ms |
コンパイル使用メモリ | 195,688 KB |
最終ジャッジ日時 | 2025-01-09 02:34:56 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using PII = pair<ll, ll>; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() template<typename T> void chmin(T &a, const T &b) { a = min(a, b); } template<typename T> void chmax(T &a, const T &b) { a = max(a, b); } struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio; #ifdef DEBUG_ #include "../program_contest_library/memo/dump.hpp" #else #define dump(...) #endif const ll INF = 1LL<<60; int main(void) { ll n; cin >> n; vector<ll> a(2*n); REP(i, 2*n) cin >> a[i]; vector<ll> vl(n); REP(i, n) vl[i] = (i==0?0:vl[i-1]) + a[2*i] - a[2*i+1]; vector<ll> vr(n); for(ll i=n-1; i>=0; --i) vr[i] = (i==n-1?0:vr[i+1]) + a[2*i+1] - a[2*i]; dump(vl); dump(vr); ll ret = -INF; chmax(ret, vl[n-1]); chmax(ret, vr[0]); REP(i, n-1) chmax(ret, vl[i] + vr[i+1]); cout << ret << endl; return 0; }