結果
問題 |
No.1251 絶対に間違ってはいけない最小化問題
|
ユーザー |
|
提出日時 | 2020-10-09 21:31:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 502 bytes |
コンパイル時間 | 1,518 ms |
コンパイル使用メモリ | 168,536 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2024-07-20 08:56:31 |
合計ジャッジ時間 | 12,933 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 39 |
ソースコード
#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<double> a(n),b(n); rep(i,n) cin>>a[i]; rep(i,n) cin>>b[i]; double m; if(n&1){ m = a[n/2]; }else{ m = (a[n/2-1]+a[n/2])/2.0; } double fx = 0; rep(i,n){ fx += b[i] * abs(m - a[i]); } cout << m << " " << (int)fx << endl; return 0; }