結果
問題 | No.1715 Dinner 2 |
ユーザー | SSRS |
提出日時 | 2021-10-22 21:29:48 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,119 bytes |
コンパイル時間 | 1,735 ms |
コンパイル使用メモリ | 173,424 KB |
実行使用メモリ | 7,288 KB |
最終ジャッジ日時 | 2023-10-24 12:22:24 |
合計ジャッジ時間 | 3,986 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,372 KB |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
4,372 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
4,372 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 1 ms
4,372 KB |
testcase_09 | AC | 2 ms
4,372 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 97 ms
5,968 KB |
testcase_13 | WA | - |
testcase_14 | AC | 92 ms
5,968 KB |
testcase_15 | WA | - |
testcase_16 | AC | 91 ms
5,704 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
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 | AC | 146 ms
7,288 KB |
testcase_33 | AC | 148 ms
7,288 KB |
testcase_34 | AC | 149 ms
7,288 KB |
testcase_35 | AC | 150 ms
7,288 KB |
testcase_36 | AC | 2 ms
4,372 KB |
testcase_37 | AC | 2 ms
4,372 KB |
testcase_38 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; const int INF = 100000000; int main(){ int N, D; cin >> N >> D; vector<int> P(N), Q(N); for (int i = 0; i < N; i++){ cin >> P[i] >> Q[i]; } int tv = -INF, fv = 1; while (fv - tv > 1){ int mid = (tv + fv) / 2; vector<vector<int>> dp(N, vector<int>(D, -INF)); for (int i = 0; i < D; i++){ if (-P[i] >= mid){ dp[0][i] = -P[i] + Q[i]; } } for (int i = 0; i < N - 1; i++){ vector<int> L(D + 1); L[0] = -INF; for (int j = 0; j < D; j++){ L[j + 1] = max(L[j], dp[i][j]); } vector<int> R(D + 1); R[D] = -INF; for (int j = D - 1; j >= 0; j--){ R[j] = max(R[j + 1], dp[i][j]); } for (int j = 0; j < D; j++){ int mx = max(L[j], R[j + 1]); if (mx - P[j] >= mid){ dp[i + 1][j] = mx - P[j] + Q[j]; } } } bool ok = false; for (int i = 0; i < D; i++){ if (dp[N - 1][i] != -INF){ ok = true; } } if (ok){ tv = mid; } else { fv = mid; } } cout << tv << endl; }