結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー shiomusubi496shiomusubi496
提出日時 2020-10-09 22:09:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 166,756 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2023-09-27 17:27:56
合計ジャッジ時間 18,878 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 203 ms
5,888 KB
testcase_19 AC 196 ms
5,896 KB
testcase_20 AC 114 ms
4,580 KB
testcase_21 AC 18 ms
4,376 KB
testcase_22 AC 122 ms
5,028 KB
testcase_23 AC 13 ms
4,376 KB
testcase_24 AC 161 ms
5,416 KB
testcase_25 WA -
testcase_26 AC 44 ms
4,380 KB
testcase_27 AC 14 ms
4,380 KB
testcase_28 AC 211 ms
6,208 KB
testcase_29 AC 213 ms
6,216 KB
testcase_30 AC 210 ms
6,304 KB
testcase_31 AC 215 ms
6,280 KB
testcase_32 AC 214 ms
6,220 KB
testcase_33 WA -
testcase_34 AC 214 ms
6,216 KB
testcase_35 AC 213 ms
6,216 KB
testcase_36 AC 211 ms
6,168 KB
testcase_37 AC 213 ms
6,216 KB
testcase_38 WA -
testcase_39 AC 215 ms
6,164 KB
testcase_40 AC 213 ms
6,256 KB
testcase_41 WA -
testcase_42 AC 211 ms
6,212 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  long double mn=1000000,mx=-1000000;
  for(int &i:A){
    cin>>i;
    mn=min(mn,(long double)i),mx=max(mx,(long double)i);
  }
  for(int &i:B)cin>>i;
  for(int I=0;I<200;I++){
    long double l=(mn*2+mx)/3.0,r=(mn+mx*2)/3.0,cnt1=0,cnt2=0;
    for(int i=0;i<N;i++){
      cnt1+=abs(A[i]-l)*B[i];
      cnt2+=abs(A[i]-r)*B[i];
    }
    if(cnt1<cnt2)mx=r;
    else mn=l;
  }
  long double ans=0.9;
  for(int i=0;i<N;i++)ans+=abs(A[i]-mn)*B[i];
  cout<<mn<<' '<<(int)ans<<endl;
}
0