結果
| 問題 | No.1251 絶対に間違ってはいけない最小化問題 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-10-09 21:46:42 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 602 bytes | 
| コンパイル時間 | 1,734 ms | 
| コンパイル使用メモリ | 174,368 KB | 
| 実行使用メモリ | 9,932 KB | 
| 最終ジャッジ日時 | 2024-07-20 10:26:52 | 
| 合計ジャッジ時間 | 15,304 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 6 WA * 36 | 
ソースコード
#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<long double,long double>> 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.precision(9);
    cout << x << " " << (int)fx << endl;
    return 0;
}
            
            
            
        