結果
問題 | No.2354 Poor Sight in Winter |
ユーザー |
|
提出日時 | 2023-06-16 21:35:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 1,947 bytes |
コンパイル時間 | 1,883 ms |
コンパイル使用メモリ | 194,280 KB |
最終ジャッジ日時 | 2025-02-14 04:39:22 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include<bits/stdc++.h>#define fi first#define se second#define eb emplace_back#define mp make_pairusing namespace std;typedef long double ld;typedef long long ll;typedef unsigned long long ull;typedef __int128 i128;template<typename T,typename U>T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}template<typename T,typename U>T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}template<class T,class S>bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}template<class T,class S>bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}int popcnt(int x) {return __builtin_popcount(x);}int popcnt(ll x) {return __builtin_popcountll(x);}int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}#define int long long#define rep(i,a,b) for(int i=(a);i<=(b);i++)#define per(i,a,b) for(int i=(a);i>=(b);i--)typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<pii> vp;int read() {int x=0,w=1; char c=getchar();while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}return x*w;}const int N=505,inf=1e9;int e[N][N],n,x[N],y[N],k,d[N];bool work(int p) {rep(i,0,n+1) rep(j,0,n+1) {int dis=abs(x[i]-x[j])+abs(y[i]-y[j]);e[i][j]=max(1ll,(dis+p-1)/p)-1;}static bool vst[N]; rep(i,0,n+2) vst[i]=0;rep(i,0,n+2) d[i]=inf; d[0]=0;rep(i,0,n+1) {int u=n+2;rep(j,0,n+1) if(!vst[j]&&d[j]<d[u]) u=j;vst[u]=1;rep(v,1,n+1) d[v]=min(d[v],d[u]+e[u][v]);}return d[n+1]<=k;}signed main() {n=read(), k=read();x[0]=read(), y[0]=read(), x[n+1]=read(), y[n+1]=read();rep(i,1,n) x[i]=read(), y[i]=read();int l=1,r=inf,ans=inf;while(l<=r) {int mid=l+r>>1;if(work(mid)) ans=mid, r=mid-1;else l=mid+1;}printf("%lld\n",ans);return 0;}