結果
問題 |
No.3268 As Seen in Toasters
|
ユーザー |
![]() |
提出日時 | 2025-09-13 00:11:29 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,576 bytes |
コンパイル時間 | 3,405 ms |
コンパイル使用メモリ | 290,344 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-13 00:11:36 |
合計ジャッジ時間 | 6,463 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 WA * 4 |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int n; IN(n); vector<int64_t> a(n); IN(a); ranges::sort(a); int64_t ans = 0; for (int64_t e : a) { ans += 2 * abs(e); } int m = int(ranges::lower_bound(a, 0) - a.begin()); for (int i : Rep(m, n - 1)) { ans -= 2 * a[i]; } ans -= abs(a[0]) + abs(a[1]) + abs(a.back()) - min({abs(a[0]), abs(a[1]), abs(a.back())}); OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include <bits/stdc++.h> template <class T> concept MyRange = std::ranges::range<T> && !std::convertible_to<T, std::string_view>; template <class T> concept MyTuple = std::__is_tuple_like<T>::value && !MyRange<T>; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1