結果
問題 |
No.3066 Collecting Coins Speedrun 1
|
ユーザー |
|
提出日時 | 2025-03-21 21:34:34 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 421 bytes |
コンパイル時間 | 3,027 ms |
コンパイル使用メモリ | 276,656 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-21 21:34:39 |
合計ジャッジ時間 | 4,376 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int N; cin >> N; vector<ll> neg, pos; for(int i = 0; i < N; i++) { int a; cin >> a; if(a < 0) neg.push_back(a); else pos.push_back(a); } ll ans = 0; if(!neg.empty()) ans += abs(neg.front())*2; if(!pos.empty()) ans += abs(pos.back())*2; cout << ans << endl; }