結果

問題 No.999 てん vs. ほむ
ユーザー gg_hatanogg_hatano
提出日時 2020-03-09 13:14:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 167,960 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 21:01:21
合計ジャッジ時間 3,904 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> v(2*n);

  for(int i = 0; i < 2*n; i++){
    cin >> v.at(i);
  }

  int left = 0;
  int right = 2 * n -1;
  ll score = 0;

  for(int i = 0; i < n; i++){
    ll l = v.at(left) - v.at(left + 1);
    ll r = v.at(right) - v.at(right -1);

    if(r >= l){
      score += r;
      right -= 2;
    } else {
      score += l;
      left += 2;
    }
  }
  cout << score << endl;

}
0