結果

問題 No.710 チーム戦
ユーザー ngtkanangtkana
提出日時 2019-08-15 21:42:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 3,000 ms
コード長 1,968 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 206,876 KB
実行使用メモリ 43,344 KB
最終ジャッジ日時 2023-10-19 19:26:28
合計ジャッジ時間 6,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,064 KB
testcase_01 AC 8 ms
5,856 KB
testcase_02 AC 108 ms
43,344 KB
testcase_03 AC 109 ms
43,344 KB
testcase_04 AC 108 ms
43,344 KB
testcase_05 AC 108 ms
43,344 KB
testcase_06 AC 108 ms
43,344 KB
testcase_07 AC 108 ms
43,344 KB
testcase_08 AC 108 ms
43,344 KB
testcase_09 AC 110 ms
43,344 KB
testcase_10 AC 108 ms
43,344 KB
testcase_11 AC 109 ms
43,344 KB
testcase_12 AC 108 ms
43,344 KB
testcase_13 AC 109 ms
43,344 KB
testcase_14 AC 109 ms
43,344 KB
testcase_15 AC 110 ms
43,344 KB
testcase_16 AC 110 ms
43,344 KB
testcase_17 AC 109 ms
43,344 KB
testcase_18 AC 110 ms
43,344 KB
testcase_19 AC 109 ms
43,344 KB
testcase_20 AC 109 ms
43,344 KB
testcase_21 AC 109 ms
43,344 KB
testcase_22 AC 108 ms
43,344 KB
testcase_23 AC 109 ms
43,344 KB
testcase_24 AC 108 ms
43,344 KB
testcase_25 AC 4 ms
4,536 KB
testcase_26 AC 4 ms
4,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_geneous = 0; ngtkana_is_geneous < n; ngtkana_is_geneous++)
#define rep(i, begin, end) for(int i = begin; i < end; i++)

template <typename T>
auto make_vector(size_t sz, T t) {
  return std::vector<T>(sz, t);
}
template <size_t N, typename T, typename U, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz, U u) {
  return make_vector(sz, T(u));
}
template <size_t N, typename T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t sz) {
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args, std::enable_if_t<
  N != 1, std::nullptr_t> = nullptr>
auto make_higher_vector(size_t a, Args... args) {
  return make_vector(a, make_higher_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

template<typename T, typename U>
inline auto cmn (T& a, U b) {if (a > b) {a = b; return true;} return false;}
template<typename T, typename U>
inline auto cmx (T& a, U b) {if (a < b) {a = b; return true;} return false;}

int main()
{
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n), b(n);
  rep(i, 0, n) std::cin >> a.at(i) >> b.at(i);
  int max = 100'000;
  constexpr int inf = 1 << 30;
  auto dp = make_higher_vector<2, int>(n + 1, max + 1, inf);
  at(dp, 0, 0) = 0;
  rep(i, 0, n) rep(j, 0, max + 1)
  {
    auto crr = at(dp, i, j);
    if (j < max) cmn(at(dp, i, j + 1), crr);
    if (i < n)
    {
      if (j + a.at(i) <= max) {
        cmn(at(dp, i + 1, j + a.at(i)), crr);
      }
      cmn(at(dp, i + 1, j), crr + b.at(i));
    }
  }
  int ret = inf;
  rep(j, 0, max + 1)
  {
    cmn(ret, std::max(j, at(dp, n, j)));
  }
  std::cout << ret << std::endl;
  return 0;
}
0