結果

問題 No.3066 Collecting Coins Speedrun 1
ユーザー tobbie
提出日時 2025-04-07 07:47:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 1,847 ms
コンパイル使用メモリ 163,664 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-07 07:47:30
合計ジャッジ時間 3,376 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)
using ll = long long int;

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  int maxv = *max_element(c.begin(), c.end());
  int minv = *min_element(c.begin(), c.end());
  if ((maxv > 0 && minv > 0) || (maxv< 0 && minv < 0))
    cout << max(abs(maxv), abs(minv)) * 2 << endl;
  else
    cout << abs(maxv)*2 + abs(minv)*2 << endl;
  return 0;
}
0