結果

問題 No.2354 Poor Sight in Winter
ユーザー RubikunRubikun
提出日時 2023-06-16 22:14:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,549 bytes
コンパイル時間 2,005 ms
コンパイル使用メモリ 200,616 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 20:16:16
合計ジャッジ時間 4,028 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 22 ms
4,380 KB
testcase_12 AC 22 ms
4,380 KB
testcase_13 AC 32 ms
4,380 KB
testcase_14 AC 32 ms
4,380 KB
testcase_15 AC 32 ms
4,376 KB
testcase_16 AC 31 ms
4,380 KB
testcase_17 AC 32 ms
4,380 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 23 ms
4,380 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 8 ms
4,376 KB
testcase_23 AC 7 ms
4,376 KB
testcase_24 AC 18 ms
4,380 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=505,INF=1<<30;

ll dis[MAX];
int X[MAX],Y[MAX];
bool kaku[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    int K;cin>>K;
    int sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;
    for(int i=1;i<=N;i++){
        cin>>X[i]>>Y[i];
    }
    X[0]=sx;
    Y[0]=sy;
    
    X[N+1]=gx;
    Y[N+1]=gy;
    
    int left=0,right=3e5;
    while(right-left>1){
        int mid=(left+right)/2;
        for(int i=0;i<MAX;i++){
            dis[i]=INF;
            kaku[i]=false;
        }
        dis[0]=0;
        for(int t=0;t<N+2;t++){
            pair<ll,int> mi=mp(INF,INF);
            for(int i=0;i<N+2;i++){
                if(!kaku[i]){
                    chmin(mi,mp(dis[i],i));
                }
            }
            int u=mi.se;
            kaku[u]=true;
            for(int j=0;j<N+2;j++){
                if(kaku[j]) continue;
                chmin(dis[j],dis[u]+((abs(X[u]-X[j])+abs(Y[u]-Y[j])-1)/mid));
            }
        }
        
        if(dis[N+1]<=K) right=mid;
        else left=mid;
    }
    
    cout<<right<<endl;
}
0