結果

問題 No.2354 Poor Sight in Winter
ユーザー norikamenorikame
提出日時 2023-06-16 22:51:22
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,340 bytes
コンパイル時間 5,391 ms
コンパイル使用メモリ 313,368 KB
実行使用メモリ 5,568 KB
最終ジャッジ日時 2023-09-06 21:28:02
合計ジャッジ時間 6,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 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,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 43 ms
5,568 KB
testcase_12 AC 45 ms
5,288 KB
testcase_13 AC 53 ms
5,340 KB
testcase_14 AC 53 ms
5,312 KB
testcase_15 AC 49 ms
5,236 KB
testcase_16 AC 51 ms
5,488 KB
testcase_17 AC 53 ms
5,276 KB
testcase_18 AC 24 ms
4,528 KB
testcase_19 AC 40 ms
4,852 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 36 ms
4,760 KB
testcase_25 AC 9 ms
4,376 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n+2), y(n+2);
	cin >> x[n] >> y[n] >> x[n+1] >> y[n+1];
	rep(i, n) cin >> x[i] >> y[i];
	int li = 0, ri = (int)(2e5);
	while (ri-li > 1) {
		int ci = ri - (ri-li) / 2;
		vector<vector<pair<int, int>>> g(n+2);
		rep(i, n+2) rep3(j, i+1, n+2) {
			int dist = abs(x[i]-x[j]) + abs(y[i]-y[j]), cost = (dist + ci - 1) / ci - 1;
			g[i].emplace_back(j, cost);
			g[j].emplace_back(i, cost);
		}
		vector<int> dp(n+2, INF);
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
		dp[n] = 0;
		pq.emplace(0, n);
		while (!pq.empty()) {
			auto [di, vi] = pq.top(); pq.pop();
			if (dp[vi] != di) continue;
			for (auto [ti, ncost] : g[vi]) {
				int ndi = di + ncost;
				if (dp[ti] <= ndi) continue;
				dp[ti] = ndi;
				pq.emplace(ndi, ti);
			}
		}
		if (dp[n+1] <= k) ri = ci;
		else li = ci;
	}
	cout << ri << endl;
	return 0;
}
0