結果
問題 |
No.3268 As Seen in Toasters
|
ユーザー |
|
提出日時 | 2025-09-19 15:59:28 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 5,358 ms |
コンパイル使用メモリ | 335,248 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-19 15:59:37 |
合計ジャッジ時間 | 8,090 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; const ll MOD = 998244353; #include<atcoder/all> using namespace atcoder; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n;cin>>n; vector<ll> A(n); rep(i,n)cin>>A[i]; sort(all(A)); ll ans=0; rep(i,n-1){ if(A[i]<0&&A[i+1]<0){ ans+=-(A[i]+A[i+1]); }else{ ans+=A[i+1]-A[i]; } } if(A[1]<0&&(-A[1]>A[n-1])){ ans-=-A[1]-A[n-1]; } cout<<ans<<endl; }