結果

問題 No.3066 Collecting Coins Speedrun 1
ユーザー forest3
提出日時 2025-03-23 17:05:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 161,532 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-23 17:05:40
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

int main() {
	int N;
	cin >> N;
	vector<int> c(N);
	rep(i, N) cin >> c[i];
	int ans = 1e9;
	if(c[0] >= 0) ans = c[N - 1] * 2;
	else if(c[N - 1] <= 0) ans = abs(c[0]) * 2;
	else ans = (abs(c[0]) + c[N - 1]) * 2;
	cout << ans << endl;
} 
0