結果

問題 No.2157 崖
ユーザー hourenhouren
提出日時 2022-12-09 22:04:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,094 bytes
コンパイル時間 1,936 ms
コンパイル使用メモリ 167,304 KB
実行使用メモリ 14,024 KB
最終ジャッジ日時 2024-04-22 22:11:48
合計ジャッジ時間 11,070 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
12,032 KB
testcase_01 AC 8 ms
11,904 KB
testcase_02 AC 8 ms
11,904 KB
testcase_03 AC 8 ms
12,032 KB
testcase_04 AC 8 ms
12,032 KB
testcase_05 AC 9 ms
12,032 KB
testcase_06 AC 8 ms
12,032 KB
testcase_07 AC 8 ms
12,160 KB
testcase_08 AC 9 ms
12,032 KB
testcase_09 AC 9 ms
12,160 KB
testcase_10 AC 8 ms
12,032 KB
testcase_11 AC 8 ms
12,160 KB
testcase_12 AC 8 ms
12,032 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL <<62);
constexpr int INF = 2e9;
int dp[1500][1500];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<vector<int>> a(1500, vector<int>(1500));
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
            dp[i][j] = INF;
        }
    }
    rep(i,m) dp[0][i] = 0;
    rep(i,n-1){
        rep(j,m){
            rep(k,m){
                if(a[i+1][j]<a[i][k]) continue;
                chmin(dp[i+1][j], max(a[i+1][j]-a[i][k], dp[i][k]));
            }
        }
    }
    int ans = INF;
    rep(i,m) chmin(ans, dp[n-1][i]);
    if(ans==INF) ans = -1;
    cout << ans << '\n';
    return 0;
}
0