結果

問題 No.168 ものさし
ユーザー beetbeet
提出日時 2018-11-23 13:00:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 939 bytes
コンパイル時間 1,924 ms
コンパイル使用メモリ 201,800 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 04:09:47
合計ジャッジ時間 4,232 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 24 ms
4,376 KB
testcase_12 AC 85 ms
4,380 KB
testcase_13 AC 116 ms
4,380 KB
testcase_14 AC 116 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 179 ms
4,380 KB
testcase_20 AC 191 ms
4,376 KB
testcase_21 AC 188 ms
4,380 KB
testcase_22 AC 185 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];

  auto dist=
    [&](Int a,Int b){
      Int v=(x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
      Int l=0,r=1e9;
      while(l+1<r){
        Int m=(l+r)>>1;
        if(m*m*100>=v) r=m;
        else l=m;
      }
      return r*10;
    };
  
  const Int INF = 1e15;
  vector<Int> dp(n,INF),used(n,0);
  dp[0]=0;  
  for(Int t=0;t<n;t++){
    Int v=-1;
    for(Int i=0;i<n;i++){
      if(used[i]) continue;
      if(v<0||dp[v]>dp[i]) v=i;
    }
    if(v<0) break;    
    used[v]=1;
    for(Int i=0;i<n;i++)
      chmin(dp[i],max(dp[v],dist(v,i)));
  }
  
  cout<<dp[n-1]<<endl;
  return 0;
}
0