結果
| 問題 |
No.2157 崖
|
| コンテスト | |
| ユーザー |
keisuke6
|
| 提出日時 | 2022-12-02 15:41:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,036 bytes |
| コンパイル時間 | 2,232 ms |
| コンパイル使用メモリ | 203,520 KB |
| 最終ジャッジ日時 | 2025-02-09 03:11:39 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 4 WA * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int N,M;
cin>>N>>M;
vector<vector<int>> D(N,vector<int>(M));
for(int i=0;i<N;i++)for(int j=0;j<M;j++) cin>>D[i][j];
int l = -1, r = 2e9;
while(r-l > 1){
int lim = (l+r)/2;
bool ok = false;
vector<vector<bool>> dp(N,vector<bool>(M,false));
for(int i=0;i<M;i++) dp[0][i] = true;
for(int i=1;i<N;i++){
int ind_l = 0, ind_r = 0, count = 0;
for(int j=0;j<M;j++){
while(ind_l < M && D[i-1][ind_l] < D[i][j]-lim){
if(dp[i-1][ind_l]) count--;
ind_l++;
}
while(ind_r < M && D[i-1][ind_r] <= D[i][j]){
if(dp[i-1][ind_r]) count++;
ind_r++;
}
dp[i][j] = (count > 0);
}
}
for(int i=0;i<M;i++)if(dp[N-1][i]) ok = true;
if(ok) r = lim;
else l = lim;
}
cout<<r<<endl;
}
keisuke6