結果

問題 No.2354 Poor Sight in Winter
ユーザー planesplanes
提出日時 2023-06-16 22:37:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 3,207 ms
コンパイル使用メモリ 174,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 21:00:07
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 53 ms
4,380 KB
testcase_12 AC 52 ms
4,380 KB
testcase_13 AC 64 ms
4,376 KB
testcase_14 AC 66 ms
4,380 KB
testcase_15 AC 62 ms
4,380 KB
testcase_16 AC 65 ms
4,380 KB
testcase_17 AC 61 ms
4,380 KB
testcase_18 AC 23 ms
4,380 KB
testcase_19 AC 42 ms
4,376 KB
testcase_20 AC 26 ms
4,380 KB
testcase_21 AC 3 ms
4,384 KB
testcase_22 AC 13 ms
4,380 KB
testcase_23 AC 13 ms
4,380 KB
testcase_24 AC 36 ms
4,376 KB
testcase_25 AC 10 ms
4,376 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=1e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
ll N,K;cin>>N>>K;

vector<ll> x(N+2),y(N+2);
cin>>x[0]>>y[0];
cin>>x[N+1]>>y[N+1];
for(ll i=1;i<=N;i++) cin>>x[i]>>y[i];


ll s=1;
ll g=3e5;


while(s<g) {
  ll k=(s+g)/2;


  priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> S;
  S.push(make_pair(0,0));
vector<ll> d(N+2,INF);
d[0]=0;

  while(!S.empty()) {
    auto p=S.top();
    S.pop();
   if(d[p.second]<p.first) continue;
   


    
    for(ll i=0;i<N+2;i++) {
      if(i==p.second) continue;

    ll cost=abs(x[i]-x[p.second])+abs(y[i]-y[p.second]);
    if(cost%k==0) cost=cost/k-1;
    else cost/=k;

    if(p.first+cost<d[i]) {
      d[i]=p.first+cost;
      S.push(make_pair(d[i],i));
    }
    }
  }

if(d[N+1]<=K) g=k;
else s=k+1;
}



cout<<s<<endl;
}


        

0