結果
問題 | No.609 Noelちゃんと星々 |
ユーザー |
![]() |
提出日時 | 2017-12-10 07:07:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 2,118 bytes |
コンパイル時間 | 722 ms |
コンパイル使用メモリ | 95,200 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 08:21:08 |
合計ジャッジ時間 | 1,958 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15 const bool DEBUG = 1; #include <iostream> #include <vector> #include <array> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <algorithm> #include <cmath> #include <cstring> #include <complex> #include <random> #include <iomanip> #include <stdio.h> #include <sys/time.h> #include <cassert> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP; typedef pair<int, PP> IPP; typedef vector<int> VI; typedef vector<P> VP; #define omajinai ios::sync_with_stdio(false);cin.tie(0) #define FOR(i,a,b) for(int i=(a);i<int(b);++i) #define REP(i,n) FOR(i,0,n) #define RFOR(i,a,b) for(int i=(b)-1;i>=int(a);--i) #define RREP(i,n) RFOR(i,0,n) #define LFOR(i,a,b) for(ll i=(a);i<(b);++i) #define LREP(i,n) LFOR(i,0,n) #define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i) #define LRREP(i,b,a) LRFOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end()) #define MP make_pair #define PB push_back #define EACH(i,c) REP(i,(int)(c).size()) #define REACH(i,c) RREP(i,(int)(c).size()) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) #define BR cout << "\n" #define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n" #define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\ <<" , "<<#y<<"="<<(y)<<"\n" #define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\ <<" , "<<#y<<"="<<(y)<<"\n"\ <<" , "<<#z<<"="<<(z)<<"\n" #define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n" const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1e9+7; ll ans; int a[100000]; int main() { omajinai; ll n; cin>>n; REP(i, n){ cin >> a[i]; } sort(a, a+n); ll k; k=0; REP(i, n) k += abs((ll)a[i] - a[n/2]); ans = k; k=0; REP(i, n) k += abs((ll)a[i] - a[min(n-1, n/2+1)]); ans = min(ans, k); cout<<ans<<endl; // if(1){ // cout << "Yes" << endl; // }else{ // cout << "No" << endl; // } }