結果
問題 | No.1715 Dinner 2 |
ユーザー |
|
提出日時 | 2021-10-25 15:50:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 844 bytes |
コンパイル時間 | 645 ms |
コンパイル使用メモリ | 67,988 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-03 07:37:23 |
合計ジャッジ時間 | 2,343 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 38 |
ソースコード
#include <iostream>#include <algorithm>using namespace std;const int inf = 1000000000;int n, m, p0[1009], p1[1009];bool ps(int l){int mx0 = 0, mx1 = -inf, p = 0;for (int i = 1; i <= n; i++) {int tmx0 = -inf, tmx1 = -inf, tp = 0;for (int j = 1; j <= m; j++) {int t = mx0;if (p == j) t = mx1;if (t - p0[j] < l) continue;t = t - p0[j] + p1[j];if (tmx0 <= t) {tmx1 = tmx0;tmx0 = t;tp = j;}else if (tmx1 < t)tmx1 = t;}if (!tp) return false;mx0 = tmx0; mx1 = tmx1; p = tp;}return true;}int main(){ios::sync_with_stdio(false);cin.tie(0);cin >> m >> n;for (int i = 1; i <= m; i++)cin >> p0[i] >> p1[i];int s = 0, e = inf, md = (s + e) / 2;while (s < e) {if (ps(-md)) e = md;else s = md + 1;md = (s + e) / 2;}cout << -md << '\n';return 0;}