結果

問題 No.999 てん vs. ほむ
ユーザー Konton7Konton7
提出日時 2020-03-03 02:17:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 196,492 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 23:10:53
合計ジャッジ時間 4,016 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 55 ms
5,376 KB
testcase_18 AC 55 ms
5,376 KB
testcase_19 AC 55 ms
5,376 KB
testcase_20 AC 56 ms
5,376 KB
testcase_21 AC 84 ms
5,376 KB
testcase_22 AC 83 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<int>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll n, sum;
    cin >> n;
    VL v(2 * n), s(n + 1);

    rep(i, 2 * n) cin >> v[i];
    sum = 0;
    rep(i, n)
    {
        sum += v[2 * i] - v[2 * i + 1];
    }
    s[0] = sum;
    rep(i, n)
    {
        s[i + 1] = s[i] + 2 * (v[2 * n - 1 - 2 * i] - v[2 * n - 2 - 2 * i]);
    }
    cout << *max_element(allpt(s)) << rt;

    return 0;
}
0