結果

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

ソースコード

diff #

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


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

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

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

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

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

}
0