結果

問題 No.1715 Dinner 2
ユーザー tonyu0tonyu0
提出日時 2021-10-22 23:13:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,451 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 105,176 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 15:16:24
合計ジャッジ時間 2,837 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 84 ms
4,348 KB
testcase_12 AC 67 ms
4,348 KB
testcase_13 AC 53 ms
4,348 KB
testcase_14 AC 67 ms
4,348 KB
testcase_15 AC 69 ms
4,348 KB
testcase_16 AC 61 ms
4,348 KB
testcase_17 AC 41 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 10 ms
4,348 KB
testcase_26 AC 6 ms
4,348 KB
testcase_27 AC 7 ms
4,348 KB
testcase_28 AC 9 ms
4,348 KB
testcase_29 AC 9 ms
4,348 KB
testcase_30 AC 9 ms
4,348 KB
testcase_31 AC 10 ms
4,348 KB
testcase_32 AC 99 ms
4,348 KB
testcase_33 AC 98 ms
4,348 KB
testcase_34 AC 102 ms
4,348 KB
testcase_35 AC 99 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)
#define all(a) a.begin(), a.end()
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (T &x : a) { is >> x; }
  return is;
}

constexpr long long INFL = 0x3f3f3f3f3f3f3f3fLL;

ll n, d, p[1001], q[1001];

bool c(ll x) {
  ll val = 0, mae = -1;
  rep(_, 0, d) {
    ll nval = -INFL, nmae = -1;
    rep(i, 0, n) {
      if (mae == i) continue; // ここがびみょう
      // 可能な中で市場んvalがでかくなるの
      if (val - p[i] >= x) {
        ll tmp = val - p[i] + q[i];
        if (tmp > nval) {
          nval = tmp;
          nmae = i;
        }
      }
    }
    if (nval == -INFL) return false;
    val = nval;
    mae = nmae;
  }
  return true;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> d;
  rep(i, 0, n) cin >> p[i] >> q[i];

  ll l = -INFL, r = INFL;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    if (c(m))
      l = m;
    else
      r = m;
  }
  cout << l << '\n';
  return 0;
}
0