結果
問題 | No.2157 崖 |
ユーザー | keisuke6 |
提出日時 | 2022-12-02 15:41:31 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,036 bytes |
コンパイル時間 | 2,591 ms |
コンパイル使用メモリ | 204,476 KB |
実行使用メモリ | 19,840 KB |
最終ジャッジ日時 | 2024-04-22 15:29:38 |
合計ジャッジ時間 | 16,899 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 3 ms
5,376 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 3 ms
5,376 KB |
testcase_11 | WA | - |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 5 ms
5,376 KB |
ソースコード
#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; }