結果
| 問題 |
No.3268 As Seen in Toasters
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-19 15:57:05 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 609 bytes |
| コンパイル時間 | 5,579 ms |
| コンパイル使用メモリ | 335,204 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-19 15:57:14 |
| 合計ジャッジ時間 | 8,221 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 3 |
ソースコード
#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[n-1]>0&&(-A[1]>A[n-1]))){
ans-=-A[1]-A[n-1];
}
cout<<ans<<endl;
}