結果
問題 | No.23 技の選択 |
ユーザー | not_522 |
提出日時 | 2020-01-04 12:15:00 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 8,510 bytes |
コンパイル時間 | 1,355 ms |
コンパイル使用メモリ | 112,956 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-02 08:03:18 |
合計ジャッジ時間 | 2,217 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 4 ms
5,376 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 4 ms
5,376 KB |
testcase_06 | AC | 5 ms
5,376 KB |
testcase_07 | AC | 4 ms
5,376 KB |
testcase_08 | AC | 4 ms
5,376 KB |
testcase_09 | AC | 5 ms
5,376 KB |
testcase_10 | AC | 6 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 5 ms
5,376 KB |
testcase_14 | AC | 5 ms
5,376 KB |
testcase_15 | AC | 5 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | AC | 4 ms
5,376 KB |
testcase_18 | AC | 4 ms
5,376 KB |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 4 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 7 ms
5,376 KB |
testcase_26 | AC | 3 ms
5,376 KB |
testcase_27 | AC | 5 ms
5,376 KB |
testcase_28 | AC | 5 ms
5,376 KB |
testcase_29 | AC | 5 ms
5,376 KB |
testcase_30 | AC | 7 ms
5,376 KB |
testcase_31 | AC | 7 ms
5,376 KB |
testcase_32 | AC | 5 ms
5,376 KB |
ソースコード
// This is free and unencumbered software released into the public domain. // Anyone is free to copy, modify, publish, use, compile, sell, or // distribute this software, either in source code form or as a compiled // binary, for any purpose, commercial or non-commercial, and by any // means. // In jurisdictions that recognize copyright laws, the author or authors // of this software dedicate any and all copyright interest in the // software to the public domain. We make this dedication for the benefit // of the public at large and to the detriment of our heirs and // successors. We intend this dedication to be an overt act of // relinquishment in perpetuity of all present and future rights to this // software under copyright law. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // For more information, please refer to <http://unlicense.org> /****************/ /* template.hpp */ /****************/ #include <algorithm> #include <cassert> #include <functional> #include <iomanip> #include <iostream> #include <limits> using std::cerr; using std::cout; using std::endl; using std::max; using std::min; using std::swap; struct BoolName : std::numpunct<char> { std::string t, f; BoolName(std::string t, std::string f) : t(t), f(f) {} std::string do_truename() const { return t; } std::string do_falsename() const { return f; } }; void setBoolName(std::string t, std::string f) { cout.imbue(std::locale(cout.getloc(), new BoolName(t, f))); } struct Initializer { Initializer() { cout << std::fixed << std::setprecision(15) << std::boolalpha; setBoolName("Yes", "No"); } } initializer; struct Input { bool eof; Input() : eof(false) {} operator char() { char v; while (!(this->eof = (std::scanf("%c", &v) != 1)) && std::isspace(v)) { } return v; } operator int() { int v; this->eof = (std::scanf("%d", &v) != 1); return v; } operator long() { long v; this->eof = (std::scanf("%ld", &v) != 1); return v; } operator long long() { long long v; this->eof = (std::scanf("%lld", &v) != 1); return v; } operator unsigned int() { unsigned int v; this->eof = (std::scanf("%u", &v) != 1); return v; } operator unsigned long() { unsigned long v; this->eof = (std::scanf("%lu", &v) != 1); return v; } operator unsigned long long() { unsigned long long v; this->eof = (std::scanf("%llu", &v) != 1); return v; } operator double() { double v; this->eof = (std::scanf("%lf", &v) != 1); return v; } operator long double() { long double v; this->eof = (std::scanf("%Lf", &v) != 1); return v; } void ignore() const { getchar(); } } in; template <typename T> T abs(T a) { return a >= 0 ? a : -a; } template <typename T, typename S> bool chmin(T &a, const S &b) { return a > b ? a = b, true : false; } template <typename T, typename S> bool chmax(T &a, const S &b) { return a < b ? a = b, true : false; } template <typename T, typename S> std::function<S(T)> cast() { return [](const T &t) { return static_cast<S>(t); }; } template <typename T> T copy(const T &a) { return T(a); } class ZeroPadding { public: ZeroPadding(int n) : n(n) {} int n; }; std::ostream &operator<<(std::ostream &os, const ZeroPadding &z) { os << std::setw(z.n) << std::setfill('0'); return os; } template <typename T> constexpr T inf() { return std::numeric_limits<T>::max() / 2 - 1; } /*************/ /* tuple.hpp */ /*************/ #include <tuple> template <typename... T> class Tuple : public std::tuple<T...> { public: Tuple(Input &in) : std::tuple<T...>() { (void)in; } }; template <typename T, typename... S> class Tuple<T, S...> : public std::tuple<T, S...> { public: Tuple() : std::tuple<T, S...>() {} Tuple(T t, S... s) : std::tuple<T, S...>(t, s...) {} Tuple(const std::tuple<T, S...> &t) : std::tuple<T, S...>(t) {} Tuple(Input &in) { auto a = std::tuple<T>(in); std::tuple<S...> b = Tuple<S...>(in); std::tuple<T, S...> c = std::tuple_cat(a, b); *this = c; } template <int n> auto &get() { return std::get<n>(*this); } template <int n> const auto &get() const { return std::get<n>(*this); } }; template <typename... T> Tuple<T...> makeTuple(const T &... args) { return Tuple<T...>(args...); } namespace std { template <typename... T> class tuple_size<Tuple<T...>> : public std::integral_constant<size_t, sizeof...(T)> {}; template <std::size_t I, typename... T> class tuple_element<I, Tuple<T...>> { public: using type = tuple_element_t<I, std::tuple<T...>>; }; } // namespace std /*****************/ /* container.hpp */ /*****************/ #include <vector> template <typename T> class Container : public T { private: using S = typename T::value_type; using Itr = typename T::iterator; public: Container() : T() {} Container(int n) : T(n) {} Container(int n, S s) : T(n, s) {} template <typename Itr> Container(Itr first, Itr last) : T(first, last) {} Container(const std::initializer_list<S> &v) : T(v) {} Container(int n, Input &in) { std::vector<S> v(n); for (auto &i : v) { i = in; } *this = Container<T>(v.begin(), v.end()); } S max() const { return *std::max_element(this->begin(), this->end()); } template <typename Function> auto max(Function func) const { std::vector<std::pair<decltype(func(S())), S>> res; for (const auto &i : *this) { res.emplace_back(func(i), i); } return std::max_element(res.begin(), res.end())->second; } S min() const { return *std::min_element(this->begin(), this->end()); } Tuple<S, S> minmax() const { auto itrs = std::minmax_element(this->begin(), this->end()); return Tuple<S, S>(*itrs.first, *itrs.second); } template <typename Function> auto min(Function func) const { std::vector<std::pair<decltype(func(S())), S>> res; for (const auto &i : *this) { res.emplace_back(func(i), i); } return std::min_element(res.begin(), res.end())->second; } int argmax() const { return std::distance(this->begin(), std::max_element(this->begin(), this->end())); } int argmin() const { return std::distance(this->begin(), std::min_element(this->begin(), this->end())); } int find(const S &a) const { return std::distance(this->begin(), std::find(this->begin(), this->end(), a)); } bool contains(const S &a) const { return std::find(this->begin(), this->end(), a) != this->end(); } int size() const { return T::size(); } std::pair<Itr, Itr> equal_range(const S &a) { return std::equal_range(this->begin(), this->end(), a); } template <typename Function> bool all_of(Function func) const { return std::all_of(this->begin(), this->end(), func); } template <typename Function> bool any_of(Function func) const { return std::any_of(this->begin(), this->end(), func); } template <typename Function> bool none_of(Function func) const { return std::none_of(this->begin(), this->end(), func); } int count(const S &s) const { return std::count(this->begin(), this->end(), s); } bool is_sorted() const { return std::is_sorted(this->begin(), this->end()); } void output(std::string sep = "\n", std::string end = "\n") const { bool first = true; for (const auto &i : *this) { if (!first) { cout << sep; } first = false; cout << i; } cout << end; } }; /***********/ /* map.hpp */ /***********/ #include <map> template <typename T, typename S> class Map : public Container<std::map<T, S>> { public: Map() : Container<std::map<T, S>>() {} bool contains(const T &a) const { return this->count(a) != 0; } int count(const T &t) const { return std::map<T, S>::count(t); } }; /************/ /* main.cpp */ /************/ int main() { int h(in), a(in), d(in); Map<int, double> dp; for (int i = 1; i <= h; ++i) { dp[i] = min(dp[i - a] + 1, dp[i - d] + 1.5); } cout << dp[h] << endl; }