結果
問題 |
No.1715 Dinner 2
|
ユーザー |
|
提出日時 | 2021-10-22 22:35:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 946 bytes |
コンパイル時間 | 1,679 ms |
コンパイル使用メモリ | 176,892 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-09-23 06:17:06 |
合計ジャッジ時間 | 6,046 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 34 WA * 4 |
ソースコード
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int main() { ll N, D; cin >> N >> D; vector<ll> P(N), Q(N); rep(i, 0, N) cin >> P[i] >> Q[i]; vector<vector<ll>> dp0(D, vector<ll>(N, -1e18)), dp1(D, vector<ll>(N, -1e18)); rep(i, 0, N) { dp0[0][i] = 0 - P[i]; dp1[0][i] = Q[i] - P[i]; } rep(i, 1, D) { multiset<pair<ll, ll>> ms; rep(j, 0, N) ms.insert(make_pair(-dp0[i - 1][j], -dp1[i - 1][j])); rep(j, 0, N) { ms.erase(ms.find(make_pair(-dp0[i - 1][j], -dp1[i - 1][j]))); auto x = *ms.begin(); dp0[i][j] = min(-x.first, -x.second - P[j]); dp1[i][j] = -x.second - P[j] + Q[j]; ms.insert(make_pair(-dp0[i - 1][j], -dp1[i - 1][j])); } } ll ans = -1e18; rep(i, 0, N) ans = max(ans, dp0[D - 1][i]); cout << ans << endl; }