結果
| 問題 |
No.2157 崖
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-10 00:04:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 724 bytes |
| コンパイル時間 | 2,211 ms |
| コンパイル使用メモリ | 199,556 KB |
| 最終ジャッジ日時 | 2025-02-09 08:57:12 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 8 |
ソースコード
#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;
}