結果
問題 |
No.1251 絶対に間違ってはいけない最小化問題
|
ユーザー |
|
提出日時 | 2020-10-15 22:07:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 794 bytes |
コンパイル時間 | 1,771 ms |
コンパイル使用メモリ | 173,712 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-20 20:00:31 |
合計ジャッジ時間 | 15,231 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 42 |
ソースコード
#include <algorithm> #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define ld long double #define INF 1000000000000000000 typedef pair<ll, ll> pll; typedef pair<int, int> pint; vector<ll> A, B; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; A.resize(N), B.resize(N); rep(i, N) { cin >> A[i]; } rep(i, N) { cin >> B[i]; } ld med; sort(all(A)); if (A.size() % 2 == 0) { med = (A[A.size() / 2 - 1] + A[A.size() / 2]) / 2; } else { med = A[A.size() / 2]; } ld ans = 0; rep(i, N) { ans += B[i] * abs(A[i] - med); } cout << fixed << setprecision(10) << med << " " << ans << endl; }