結果

問題 No.999 てん vs. ほむ
ユーザー aaaaaa
提出日時 2020-03-30 12:13:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,541 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 96,768 KB
実行使用メモリ 4,756 KB
最終ジャッジ日時 2023-09-02 12:15:30
合計ジャッジ時間 3,531 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    deque<ll> A(2 * N);
    REP(i, 2 * N) cin >> A[i];

    ll user_a = 0;
    ll user_b = 0;
    ll left = 0;
    ll right = 2 * N - 1;
    REP(i, N) {
        ll left_score_diff = A[left] - A[left + 1];
        ll right_score_diff = A[right] - A[right - 1];
        debug(left_score_diff, right_score_diff);
        if (left_score_diff >= right_score_diff) {
            user_a += A[left];
            user_b += A[left + 1];
            left += 2;
        } else {  // right
            user_a += A[right];
            user_b += A[right - 1];
            right -= 2;
        }
        debug(user_a, user_b, left, right);
    }
    debug(user_a, user_b);
    cout << user_a - user_b << endl;

    return 0;
}
0