結果

問題 No.2157 崖
ユーザー umimelumimel
提出日時 2022-12-09 22:23:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,633 ms / 6,000 ms
コード長 1,295 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 173,040 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-04-22 22:34:08
合計ジャッジ時間 25,142 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1,664 ms
13,696 KB
testcase_14 AC 2,139 ms
18,048 KB
testcase_15 AC 2,352 ms
13,568 KB
testcase_16 AC 2,346 ms
13,696 KB
testcase_17 AC 1,872 ms
15,744 KB
testcase_18 AC 1,831 ms
15,488 KB
testcase_19 AC 2,285 ms
16,256 KB
testcase_20 AC 2,633 ms
19,328 KB
testcase_21 AC 2,541 ms
19,328 KB
testcase_22 AC 1,772 ms
15,104 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<vector<ll>> d(n, vector<ll>(m));
    rep(i, n) rep(j, m) cin >> d[i][j];
    rep(i, n) sort(all(d[i]));

    ll lw = -1;
    ll hi = 1e9;
    ll mid;
    bool isExist = false;
    while(hi-lw>1){
        mid = (lw+hi)/2;
        
        bool flag = true;
        vector<ll> pre, now;
        rep(j, m) pre.pb(d[0][j]);
        for(ll i=1; i<n; i++){
            now.clear();
            rep(j, m){
                auto itr1 = lower_bound(all(pre), d[i][j]-mid);
                auto itr2 = upper_bound(all(pre), d[i][j]);
                if(itr1 != itr2) now.pb(d[i][j]);
            }

            if((ll)now.size()==0) flag=false;
            swap(pre, now);
        }

        if(flag){
            hi=mid;
            isExist=true;
        }else{
            lw=mid;
        }
    }

    if(isExist) cout << hi << endl;
    else cout << -1 << endl;
}
0