結果

問題 No.999 てん vs. ほむ
ユーザー rok_dwrok_dw
提出日時 2020-03-19 18:01:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 163,588 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 21:00:42
合計ジャッジ時間 5,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD


const int N = 10e4+1;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    int a[N];

    int lp=1;
    int rp=n*2;

    FOR(i,1,2*n+1)
        cin>>a[i];
        
    ll ans = 0;
    while(lp<rp){
        if(a[lp]-a[lp+1]>a[rp]-a[rp-1]){
            ans += a[lp]-a[lp+1];
            lp += 2;
        }else{
            ans += a[rp]-a[rp-1];
            rp-=2;
        }
    }

    cout << ans << endl;
    return 0;
}
0