結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-13 23:48:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 1,631 bytes |
| コンパイル時間 | 2,060 ms |
| コンパイル使用メモリ | 201,764 KB |
| 最終ジャッジ日時 | 2025-02-13 00:14:53 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#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";
}