結果

問題 No.999 てん vs. ほむ
ユーザー uryo1903uryo1903
提出日時 2020-02-28 21:31:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,432 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 163,608 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 17:55:32
合計ジャッジ時間 3,291 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  int sum1 = 0, sum2 = 0;
  vector<int> a(n*2);

  for(int i = 0; i < n*2; ++i){
    cin >> a[i];
  }

  int l = 0, r = n * 2-2;
  for(int i = 0; i < n; ++i){
    if(a[l] - a[l+1]  > a[r+1] - a[r]){
      sum1 += a[l];
      sum2 += a[l+1];
      l += 2;
    }else{
      sum1 += a[r+1];
      sum2 += a[r];
      r -= 2;
    }
  }

  cout << sum1 - sum2 << '\n';

  return 0;
}
0