結果
| 問題 |
No.838 Noelちゃんと星々3
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2019-06-14 22:49:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 1,725 ms |
| コンパイル使用メモリ | 175,232 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-14 07:53:12 |
| 合計ジャッジ時間 | 3,155 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;
int main(){
int N;cin>>N;
vector<ll> S(N);
vector<bool> T(N,0);
for(int i=0;i<N;i++){
cin>>S[i];
}
sort(all(S));
ll sum=0;
for(int i=0;i<N;i++){
if(i==0){
sum+=S[1]-S[0];
S[0]=S[1];
}else if(i!=N-1){
if(S[i]==S[i-1]) continue;
else if(S[i]==S[i+1]) continue;
else if(S[i]-S[i-1]<S[i+1]-S[i]){
sum+=S[i]-S[i-1];
S[i]=S[i-1];
}else{
sum+=S[i+1]-S[i];
S[i]=S[i+1];
}
}else sum+=S[i]-S[i-1];
}
cout<<sum<<endl;
}
Rubikun