結果
| 問題 |
No.3268 As Seen in Toasters
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2025-09-12 23:44:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,647 bytes |
| コンパイル時間 | 3,622 ms |
| コンパイル使用メモリ | 293,336 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-09-12 23:47:45 |
| 合計ジャッジ時間 | 5,866 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 22 |
ソースコード
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
void Solve() {
int n;
IN(n);
vector<int> a, b;
int64_t ans = 0;
while (n--) {
int x;
IN(x);
if (x > 0) {
a.push_back(x);
} else {
b.push_back(abs(x));
}
ans += 2 * abs(x);
}
ranges::sort(a);
if (!a.empty()) {
b.push_back(a[0]);
}
ranges::sort(b, greater{});
ans -= b[0] + b[1];
n = Sz(a);
for (int i : Rep(1, n)) {
ans -= 2 * a[i - 1];
}
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 Sz(r) int(size(r))
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')
#endif // __INCLUDE_LEVEL__ == 1
risujiroh