結果

問題 No.999 てん vs. ほむ
ユーザー a0171610a0171610
提出日時 2020-04-10 20:52:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 1,887 ms
コンパイル使用メモリ 167,848 KB
実行使用メモリ 11,364 KB
最終ジャッジ日時 2023-10-13 17:25:12
合計ジャッジ時間 9,427 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

signed main(){
  lint N; cin >> N;
  vector<lint> a(2*N);
  for(lint i = 0; i < a.size(); i++) cin >> a[i];
  lint ans = 0;
  for(lint i = 0; i < N; i++){
    lint n = a.size();
    lint p = a[0] - a[1];
    lint q = a[n - 1] - a[n - 2];
    if(p > q){
      a.erase(a.begin()); a.erase(a.begin());
      ans += p;
    } 
    if(p <= q){
      a.erase(a.begin() + n - 1); a.erase(a.begin() + n - 2);
      ans += q;
    }
  }
  cout << ans << endl;
}
0