結果

問題 No.2354 Poor Sight in Winter
ユーザー kumakumakumakuma
提出日時 2023-05-13 23:40:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,575 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 205,348 KB
実行使用メモリ 270,812 KB
最終ジャッジ日時 2023-08-19 19:30:59
合計ジャッジ時間 5,917 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 200000000
#define ll int
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = 3.141592653589793238462643383279;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vector<pll> points(N + 2);
  for (ll i = 0; i < N + 2; ++i) {
    cin >> points.at(i).first >> points.at(i).second;
  }
  ll l = 0, r = 200010;
  //log(10 ^ 5) ≒ 20
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    vector<ll> dp(N + 2, INF);
    dp.at(0) = 0;
    priority_queue<pll, vector<pll>, greater<pll>> q;
    q.push({0, 0});
    while (!q.empty()) {
      ll now = q.top().second, d = q.top().first;
      q.pop();
      if (d > dp.at(now)) {
        continue;
      }
      for (ll i = 0; i < N + 2; ++i) {
        ll nd = d + (abs(points.at(now).first - points.at(i).first) + abs(points.at(now).second - points.at(i).second) - 1) / m;
        if (dp.at(i) > nd) {
          dp.at(i) = nd;
          q.push({nd, i});
        }
      }
    }
    // cout << "dp" << m << "\n";
    // for (ll i = 0; i < N + 2; ++i) {
    //   cout << dp.at(i) << " ";
    // }
    // cout << "\n";
    if (dp.at(1) <= K) {
      r = m;
    }
    else {
      l = m;
    }
  }
  cout << r << "\n";
}
0