結果

問題 No.837 Noelちゃんと星々2
ユーザー dama_mathdama_math
提出日時 2019-06-14 20:08:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 980 bytes
コンパイル時間 1,819 ms
コンパイル使用メモリ 168,632 KB
実行使用メモリ 5,068 KB
最終ジャッジ日時 2023-09-02 07:17:37
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
4,944 KB
testcase_01 AC 49 ms
4,892 KB
testcase_02 AC 50 ms
4,880 KB
testcase_03 AC 49 ms
4,920 KB
testcase_04 AC 49 ms
4,888 KB
testcase_05 AC 48 ms
5,068 KB
testcase_06 AC 49 ms
4,980 KB
testcase_07 AC 47 ms
4,860 KB
testcase_08 AC 50 ms
4,936 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define ROF(i,a,b) for(int i=b-1;i>=a;--i)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

ll y[100000],d[100000];
int main(){
	int n; cin>>n;
	assert(n>=2 && n<=100000);
	FOR(i,0,n){
		cin>>y[i];
		assert(-1e9<=y[i] && y[i]<=1e9);
	}
	sort(y,y+n);
	if(y[0]==y[n-1]){
		co(1); return 0;
	}
	ll t=0;
	FOR(i,0,n-1){
		t+=y[i]-y[i/2];
		d[i]+=t;
	}
	t=0;
	ROF(i,0,n-1){
		t+=y[n-(n-i)/2]-y[i+1];
		d[i]+=t;
	}
	ll m=LINF;
	FOR(i,0,n-1) m=min(m,d[i]);
	co(m);
	return 0;
}
0