結果

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

ソースコード

diff #

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

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

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(c.begin(), c.end());
  if (c[0] * c[n-1] > 0)
    cout << max(abs(c[0]), abs(c[n-1])) * 2;
  else
    cout << abs(c[0]) + abs(c[n-1]) + abs(c[0] - c[n-1]) << endl;
  return 0;
}
0