結果

問題 No.2354 Poor Sight in Winter
ユーザー kotatsugamekotatsugame
提出日時 2023-06-16 21:43:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 70,092 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 19:08:05
合計ジャッジ時間 2,408 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,K;
int X[502],Y[502];
int dist[502];
bool used[502];
int main()
{
	cin>>N>>K;
	for(int i=0;i<N+2;i++)cin>>X[i]>>Y[i];
	N+=2;
	int LP=0,RP=(int)2e5;
	while(RP-LP>1)
	{
		int P=(LP+RP)/2;
		for(int i=0;i<N;i++)dist[i]=K+1,used[i]=false;
		dist[0]=0;
		for(int t=0;t<N;t++)
		{
			int mi=-1;
			for(int i=0;i<N;i++)if(!used[i])
			{
				if(mi==-1||dist[mi]>dist[i])mi=i;
			}
			if(mi==-1||dist[mi]>K)break;
			used[mi]=true;
			for(int j=0;j<N;j++)if(!used[j])
			{
				int t=abs(X[j]-X[mi])+abs(Y[j]-Y[mi]);
				t=(t-1)/P;
				if(dist[j]>dist[mi]+t)dist[j]=dist[mi]+t;
			}
		}
		if(dist[1]<=K)RP=P;
		else LP=P;
	}
	cout<<RP<<endl;
}
0