結果

問題 No.999 てん vs. ほむ
ユーザー Utopiosphere
提出日時 2020-02-28 21:31:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 168,824 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 16:50:35
合計ジャッジ時間 3,191 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> A(2 * N);
    for (int i = 0; i < 2 * N; i++){
        cin >> A.at(i);
    }
    int left = 0, right = 2 * N - 1;
    for (int i = 0; i < N; i++){
        if (A.at(left) - A.at(left + 1) < A.at(right) - A.at(right - 1)){
            ans += A.at(right) - A.at(right - 1);
            right -= 2;
        }
        else {
            ans += A.at(left) - A.at(left + 1);
            left += 2;
        }
    }
    cout << ans << endl;

}
0