結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 24 ms
4,348 KB
testcase_12 AC 21 ms
4,348 KB
testcase_13 AC 16 ms
4,348 KB
testcase_14 AC 20 ms
4,348 KB
testcase_15 AC 20 ms
4,348 KB
testcase_16 AC 18 ms
4,348 KB
testcase_17 AC 12 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 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 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 28 ms
4,348 KB
testcase_33 AC 28 ms
4,348 KB
testcase_34 AC 28 ms
4,348 KB
testcase_35 AC 32 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 int INF = 0x3f3f3f3f;

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

bool c(int x) {
  int val = 0, mae = -1;
  rep(_, 0, d) {
    int nval = -INF, nmae = -1;
    rep(i, 0, n) {
      if (mae == i) continue; // ここがびみょう
      // 可能な中で市場んvalがでかくなるの
      if (val - p[i] >= x) {
        int tmp = val - p[i] + q[i];
        if (tmp > nval) {
          nval = tmp;
          nmae = i;
        }
      }
    }
    if (nval == -INF) 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];

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