結果

問題 No.2157 崖
ユーザー take000take000
提出日時 2022-12-10 00:04:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 2,340 ms
コンパイル使用メモリ 203,656 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-22 23:21:19
合計ジャッジ時間 8,194 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 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 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 420 ms
10,496 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 348 ms
9,472 KB
testcase_18 AC 331 ms
9,344 KB
testcase_19 WA -
testcase_20 AC 473 ms
11,264 KB
testcase_21 AC 466 ms
11,264 KB
testcase_22 AC 317 ms
9,088 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 2e9;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int N, M;
    cin >> N >> M;
    vector D(N, vector<int>(M + 1, INF));
    rep(i, N) rep(j, M) cin >> D[i][j];
    rep(i, N) sort(D[i].begin(), D[i].end());

    int ans = INF;
    rep(i, M) {
        if (i >= M) return INF;
        int mi = D[0][i];

        int cur = mi;
        for (int j = 1; j < N; ++j) {
            cur = *lower_bound(D[j].begin(), D[j].end(), cur);
        }

        if (cur == INF) continue;
        ans = min(ans, cur - mi);
    }

    if (ans == INF) ans = -1;
    cout << ans << "\n";

    return 0;
}

0