結果

問題 No.2157 崖
ユーザー _yurimoir_yurimoir
提出日時 2022-12-09 22:25:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 4,105 ms
コンパイル使用メモリ 282,972 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-04-22 22:34:47
合計ジャッジ時間 12,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> d(n,vector<ll>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>d[i][j];
        }
        sort(d[i].begin(),d[i].end());
    }
    ll ans=1e18;
    for(int i=0;i<m;i++){
        ll v=d[0][i];
        ll local=-1;
        bool flg=true;
        for(int j=1;j<n;j++){
            auto lb=lower_bound(d[j].begin(),d[j].end(),v);
            if(lb==d[j].end()){
                flg=false;
                break;
            }
            local=max(local,(*lb-v));
            v=(*lb);
        }
        if(local<0)continue;
        if(flg)ans=min(ans,local);
    }
    if(ans==1e18){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
    return 0;
}
0