結果

問題 No.2354 Poor Sight in Winter
ユーザー kumakumakumakuma
提出日時 2023-05-13 23:48:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,631 bytes
コンパイル時間 1,952 ms
コンパイル使用メモリ 207,332 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 19:35:35
合計ジャッジ時間 3,204 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 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 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 31 ms
4,380 KB
testcase_14 AC 28 ms
4,376 KB
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 25 ms
4,376 KB
testcase_17 AC 26 ms
4,376 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 15 ms
4,376 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 13 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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 + max(0, 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});
        }
      }
      if (dp.at(1) <= K) {
        break;
      }
    }
    // 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