結果
問題 | No.2855 Move on Grid |
ユーザー | ルク |
提出日時 | 2024-08-25 16:05:23 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,467 bytes |
コンパイル時間 | 7,144 ms |
コンパイル使用メモリ | 312,476 KB |
実行使用メモリ | 218,496 KB |
最終ジャッジ日時 | 2024-08-25 16:06:24 |
合計ジャッジ時間 | 57,135 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
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 | 1,599 ms
218,368 KB |
testcase_11 | AC | 1,538 ms
218,240 KB |
testcase_12 | AC | 1,511 ms
218,240 KB |
testcase_13 | AC | 1,555 ms
218,368 KB |
testcase_14 | AC | 1,602 ms
218,368 KB |
testcase_15 | AC | 1,571 ms
218,240 KB |
testcase_16 | AC | 1,589 ms
218,240 KB |
testcase_17 | AC | 1,565 ms
218,368 KB |
testcase_18 | AC | 1,584 ms
218,240 KB |
testcase_19 | AC | 1,555 ms
218,368 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 | 1,748 ms
218,240 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #include <chrono> #include <unistd.h> using namespace std; using namespace chrono; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = n; i > 0; --i) #define bitrep(i, n) for (ll i = 0; i < (1 << n); ++i) #define all(a) (a).begin(), (a).end() #define yesNo(b) ((b) ? "Yes" : "No") using ll = long long; using ull = unsigned long long; using ld = long double; using mint = modint998244353; using MINT = modint1000000007; string alphabet = "abcdefghijklmnopqrstuvwxyz"; string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; constexpr double pi = 3.141592653589793; constexpr ll smallMOD = 998244353; constexpr ll bigMOD = 1000000007; constexpr ll dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr ll dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(15); } } init; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; rep(i, vec.size()) { os << vec[i]; if (i != vec.size() - 1) os << ", "; } os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &vec) { os << "["; rep(i, vec.size()) { os << vec[i]; if (i != vec.size() - 1) os << ", "; } os << "]"; return os; } // graph_template struct Edge { ll to; ll cost; Edge(ll to, ll cost) : to(to), cost(cost) {} bool operator>(const Edge &e) const { return cost > e.cost; } }; int main() { ll n, m, k; cin >> n >> m >> k; vector<vector<ll>> mp(n, vector<ll>(m, 0)); rep(i, n) { rep(j, m) { cin >> mp[i][j]; } } // 右にm個、下にn個移動したときのパス. vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(m, vector<ll>())); dp[0][0] = {mp[0][0]}; rep1(i, n - 1) { vector<ll> tmp = dp[i - 1][0]; tmp.push_back(mp[i][0]); sort(all(tmp)); dp[i][0] = tmp; } rep1(j, m - 1) { vector<ll> tmp = dp[0][j - 1]; tmp.push_back(mp[0][j]); sort(all(tmp)); dp[0][j] = tmp; } rep(i, n) { rep(j, m) { if (i == 0 || j == 0) continue; vector<ll> tmp1 = dp[i - 1][j]; vector<ll> tmp2 = dp[i][j - 1]; ll addNum = mp[i][j]; tmp1.push_back(addNum); tmp2.push_back(addNum); sort(all(tmp1)); sort(all(tmp2)); ll t1 = 1e9, t2 = 1e9; rep(i, tmp1.size()) { if (i < k) break; t1 = min(t1, tmp1[i]); t2 = min(t2, tmp2[i]); } if (t1 > t2) { dp[i][j] = tmp1; } else { dp[i][j] = tmp2; } } } vector<ll> last = dp[n - 1][m - 1]; sort(all(last)); rep(i, k) { if (i >= last.size()) break; last[i] = 1e9; } cout << *min_element(all(last)) << endl; return 0; }