結果
問題 |
No.3066 Collecting Coins Speedrun 1
|
ユーザー |
|
提出日時 | 2025-03-21 21:48:46 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 454 bytes |
コンパイル時間 | 3,450 ms |
コンパイル使用メモリ | 279,400 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-21 21:48:52 |
合計ジャッジ時間 | 5,289 ms |
ジャッジサーバーID (参考情報) |
judge7 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> c(n); for (int i = 0; i < n; i++) { cin >> c[i]; } sort(c.begin(), c.end()); long long ans = 0; if (c[0] <= 0 && c[n - 1] >= 0) ans = 2 * (c[n - 1] - c[0]); else if (c[0] >= 0) { ans = 2 * (c[n - 1]); } else { ans = 2 * (-1 * c[0]); } cout << ans << endl; }