結果

問題 No.999 てん vs. ほむ
ユーザー mikianaaamikianaaa
提出日時 2020-08-31 20:56:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 169,156 KB
実行使用メモリ 5,240 KB
最終ジャッジ日時 2023-08-10 17:43:19
合計ジャッジ時間 4,142 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
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 19 ms
5,008 KB
testcase_18 AC 18 ms
4,748 KB
testcase_19 AC 18 ms
5,088 KB
testcase_20 AC 19 ms
4,520 KB
testcase_21 AC 26 ms
5,060 KB
testcase_22 AC 25 ms
4,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    deque<ll> A(2 * N);
    rep(i, 2 * N) { cin >> A[i]; }

    ll homura = 0, tenpura = 0;
    while (!A.empty()) {
        ll frdiff = A[0] - A[1];
        ll badiff = A[A.size() - 1] - A[A.size() - 2];
        if (frdiff > badiff) {
            homura += A[0];
            tenpura += A[1];
            A.pop_front();
            A.pop_front();
        } else {
            homura += A[A.size() - 1];
            tenpura += A[A.size() - 2];
            A.pop_back();
            A.pop_back();
        }
    }

    cout << homura - tenpura << endl;
}
0