結果
| 問題 |
No.1251 絶対に間違ってはいけない最小化問題
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2020-10-09 22:18:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 573 bytes |
| コンパイル時間 | 2,017 ms |
| コンパイル使用メモリ | 202,688 KB |
| 最終ジャッジ日時 | 2025-01-15 04:58:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 39 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<ll> A(n),B(n);
vector<pair<ll,ll>> C(n);
rep(i,n) cin>>A[i];
rep(i,n) cin>>B[i];
rep(i,n) C[i]={A[i],B[i]};
sort(ALL(C));
vector<ll> s(n+1);
rep(i,n) s[i+1]=s[i]+C[i].second;
ll m=(s[n]+1)/2;
ll x=C[lower_bound(ALL(s),m)-s.begin()].first;
ll ans=0;
rep(i,n){
ans+=C[i].second*abs(C[i].first-x);
}
cout<<x<<" "<<ans<<endl;
return 0;
}
umezo