結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー rogi52
提出日時 2020-10-09 21:44:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 173,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 10:17:31
合計ジャッジ時間 15,131 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n; cin>>n;
    vector<pair<int,int>> p(n);
    rep(i,n) cin>>p[i].first;
    rep(i,n) cin>>p[i].second;
    sort(p.begin(),p.end());
    long double x;
    if(n&1) x = p[n/2].first;
    else x = (p[n/2-1].first+p[n/2].first)/2.0;

    long double fx = 0.0;
    rep(i,n){
        fx += p[i].second * abs(p[i].first - x);
    }
    cout << x << " " << fx << endl;
    return 0;
}
0