結果

問題 No.2157 崖
ユーザー nyyanyya
提出日時 2022-12-09 22:45:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,399 bytes
コンパイル時間 4,691 ms
コンパイル使用メモリ 227,868 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-04-22 22:47:52
合計ジャッジ時間 26,159 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2,119 ms
18,048 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1,802 ms
15,744 KB
testcase_18 AC 1,767 ms
15,616 KB
testcase_19 WA -
testcase_20 AC 2,708 ms
19,456 KB
testcase_21 AC 2,542 ms
19,328 KB
testcase_22 AC 1,648 ms
14,976 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
//using mint = modint;
using mint = modint998244353;
//using mint = modint1000000007;
using P = pair<int, int>;

const ll INF=1LL<<60, dx[]={0,1,0,-1},dy[]={1,0,-1,0};
template <typename T> inline bool chmin(T& a,const T&b) {if(a>b){a=b; return 1;} return 0;}
template <typename T> inline bool chmax(T& a,const T&b) {if(a<b){a=b; return 1;} return 0;}

int main(){

    int n,m;
    cin >> n >> m;

    vector<vector<ll>> d(n,vector<ll> (m));
    rep(i,n) {
        rep(j,m) cin >> d[i][j];
        sort(d[i].begin(),d[i].end()); 
    }

    auto check=[&](int j,long long k) -> bool {
        ll key=d[0][j]+k;
        for(int i=1;i<n;i++) {
            auto it=lower_bound(d[i].begin(), d[i].end(), key);
            if(it==d[i].end()) return false;
            key=(*it)+k;
        }
        return true;
        
    };

    ll ans=INF;
    rep(i,m){
        long long left=0;//下限
        long long right=1000000001;//上限+1
        long long mid=(left+right)/2;

        while(mid-left>0) {
            mid=(left+right)/2;
            if(check(i,mid)){
                left=mid;	
            } else {
                right=mid;
            }
        }
        chmin(ans,left-1);
    }
    
    cout << ans << endl;

    return 0;
}
0