結果

問題 No.2855 Move on Grid
ユーザー maeshunmaeshun
提出日時 2024-08-27 05:02:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,202 bytes
コンパイル時間 4,600 ms
コンパイル使用メモリ 266,592 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-08-27 05:03:00
合計ジャッジ時間 8,101 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 8 ms
6,940 KB
testcase_10 AC 40 ms
6,944 KB
testcase_11 AC 39 ms
6,944 KB
testcase_12 AC 38 ms
6,940 KB
testcase_13 AC 37 ms
6,940 KB
testcase_14 AC 37 ms
6,944 KB
testcase_15 AC 38 ms
6,940 KB
testcase_16 AC 38 ms
6,940 KB
testcase_17 AC 37 ms
6,944 KB
testcase_18 AC 36 ms
6,944 KB
testcase_19 AC 36 ms
6,940 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 56 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n)rep(j,m) cin >> a[i][j];
    ll low = 0;
    ll high = 2e9;
    if(k>=n+m) {
        cout << (int)1e9 << endl;
        return 0;
    }
    while(high-low>1) {
        ll mid = (high+low)/2;
        vector<vector<ll>> dp(n+1, vector<ll>(m+1, n*m));
        if(a[0][0]<mid) dp[0][0] = 1;
        else dp[0][0] = 0;
        rep(i,n)rep(j,m) {
            if(i+1<n) dp[i+1][j] = min(dp[i+1][j], dp[i][j]+(a[i+1][j]<mid));
            if(j+1<n) dp[i][j+1] = min(dp[i][j+1], dp[i][j]+(a[i][j+1]<mid));
        }
        if(dp[n-1][m-1]<=k) low = mid;
        else high = mid;
    }
    cout << low << endl;
    return 0;
}
0