Submission #994380
Source Code Expand
/*** Template Begin ***/ #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <tuple> #include <type_traits> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> auto init_ = [] { std::ios_base::sync_with_stdio(false); std::cout << std::fixed; return 0; }(); template <typename T> inline T in() { T x; std::cin >> x; return x; } template <typename T> inline void in(T &x) { std::cin >> x; } template <typename T, typename... Ts> inline void in(T &t, Ts &... ts) { std::cin >> t; in(ts...); } template <typename T, typename U = std::vector<T>> inline U vin(int n) { U v(n); for (int i = 0; i < n; ++i) { std::cin >> v[i]; } return v; } template <typename T, typename U = std::vector<T>, typename V = std::vector<U>> inline V vin(int h, int w) { V vv(h, U(w)); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { std::cin >> vv[i][j]; } } return vv; } template <typename T> inline void out(const T &x) { std::cout << x << std::endl; } template <char delimiter = ' ', typename T, typename... Ts> inline void out(const T &t, const Ts &... ts) { std::cout << t << delimiter; out(ts...); } template <char delimiter = ' ', typename T> inline void vout(const T &v, int n) { for (int i = 0; i < n; ++i) { if (i) std::cout << delimiter; std::cout << v[i]; } std::cout << std::endl; } template <char delimiter = ' ', typename T> inline void vout(const T &v, int h, int w) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (j) std::cout << delimiter; std::cout << v[i][j]; } std::cout << std::endl; } } template <typename T, size_t D> struct multi_vector_type { using type = std::vector<typename multi_vector_type<T, D - 1>::type>; }; template <typename T> struct multi_vector_type<T, 1> { using type = std::vector<T>; }; template <typename T> struct multi_vector_type<T, 0> { using type = T; }; template <typename T, size_t D> using multi_vector = typename multi_vector_type<T, D>::type; template <typename T, size_t D, class = typename std::enable_if<D == 0>::type> T make_vector(const T &val = T()) { return val; } template <typename T, size_t D = 1, typename... Ts, class = typename std::enable_if<D != 0>::type> multi_vector<T, D> make_vector(size_t n, Ts &&... args) { return multi_vector<T, D>(n, make_vector<T, D - 1>(args...)); } using namespace std; #define USING_BOOST #ifdef USING_BOOST #include <boost/range.hpp> #include <boost/range/adaptors.hpp> #include <boost/range/algorithm.hpp> #include <boost/range/algorithm_ext.hpp> #include <boost/range/irange.hpp> inline auto rep(int begin, int end) { if (begin > end) { return boost::irange(0, 0); } else { return boost::irange(begin, end); } } inline auto rep(int begin, int end, int step) { if ((step > 0 && begin > end) || (step < 0 && begin < end)) { return boost::irange(0, 0, step); } else { return boost::irange(begin, end, step); } } #endif #define USING_NAMESPACE #ifdef USING_NAMESPACE using namespace std; #ifdef USING_BOOST using namespace boost; using namespace boost::adaptors; #endif #endif /*** Template End ***/ int64_t n, a; unordered_map<int64_t, int> memo; int64_t dfs(int64_t m, int64_t x) { if (m >= n) { return 0; } if (memo.count((m << 32) + x)) { return memo[(m << 32) + x]; } int ret; if (m > x) { ret = min(dfs(m + x, x) + 1, dfs(0, m) + a); } else { ret = dfs(m + x, x) + 1; } return memo[(m << 32) + x] = ret; } int main() { in(n, a); assert(n <= 1000000 && a <= 1000000); out(dfs(0, 1)); }
Submission Info
Submission Time | |
---|---|
Task | E - Cookies |
User | mino |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 4268 Byte |
Status | TLE |
Exec Time | 2112 ms |
Memory | 178392 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | 0 / 500 | ||||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt |
dataset1 | sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt |
dataset2 | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-20.txt, 02-21.txt, 02-22.txt, 02-23.txt, 02-24.txt, 02-25.txt, 02-26.txt, 02-27.txt, 02-28.txt, 02-29.txt, 02-30.txt, 02-31.txt, 02-32.txt, 02-33.txt, 02-34.txt, 02-35.txt, 02-36.txt, 02-37.txt, 02-38.txt, 02-39.txt, 02-40.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | TLE | 2111 ms | 174680 KB |
01-02.txt | TLE | 2111 ms | 171992 KB |
01-03.txt | TLE | 2112 ms | 178136 KB |
01-04.txt | TLE | 2111 ms | 174168 KB |
01-05.txt | TLE | 2111 ms | 174936 KB |
01-06.txt | TLE | 2111 ms | 175704 KB |
01-07.txt | TLE | 2111 ms | 174680 KB |
01-08.txt | TLE | 2111 ms | 173272 KB |
01-09.txt | TLE | 2111 ms | 175960 KB |
01-10.txt | TLE | 2111 ms | 174296 KB |
01-11.txt | TLE | 2111 ms | 175576 KB |
01-12.txt | TLE | 2111 ms | 173016 KB |
01-13.txt | TLE | 2112 ms | 178392 KB |
01-14.txt | AC | 292 ms | 33936 KB |
01-15.txt | TLE | 2111 ms | 175448 KB |
01-16.txt | TLE | 2111 ms | 172120 KB |
01-17.txt | TLE | 2111 ms | 177240 KB |
01-18.txt | AC | 3 ms | 256 KB |
01-19.txt | AC | 3 ms | 256 KB |
01-20.txt | AC | 3 ms | 256 KB |
01-21.txt | AC | 3 ms | 256 KB |
01-22.txt | AC | 3 ms | 256 KB |
01-23.txt | AC | 3 ms | 384 KB |
01-24.txt | AC | 3 ms | 256 KB |
01-25.txt | AC | 3 ms | 256 KB |
01-26.txt | AC | 3 ms | 256 KB |
02-01.txt | RE | 113 ms | 256 KB |
02-02.txt | RE | 112 ms | 256 KB |
02-03.txt | RE | 114 ms | 256 KB |
02-04.txt | RE | 114 ms | 256 KB |
02-05.txt | RE | 113 ms | 256 KB |
02-06.txt | RE | 112 ms | 256 KB |
02-07.txt | RE | 112 ms | 256 KB |
02-08.txt | RE | 114 ms | 256 KB |
02-09.txt | RE | 111 ms | 256 KB |
02-10.txt | RE | 113 ms | 256 KB |
02-11.txt | RE | 112 ms | 256 KB |
02-12.txt | RE | 114 ms | 256 KB |
02-13.txt | RE | 112 ms | 256 KB |
02-14.txt | RE | 111 ms | 256 KB |
02-15.txt | RE | 114 ms | 256 KB |
02-16.txt | RE | 115 ms | 256 KB |
02-17.txt | RE | 117 ms | 256 KB |
02-18.txt | RE | 114 ms | 256 KB |
02-19.txt | RE | 113 ms | 256 KB |
02-20.txt | RE | 112 ms | 256 KB |
02-21.txt | RE | 112 ms | 256 KB |
02-22.txt | RE | 112 ms | 256 KB |
02-23.txt | RE | 113 ms | 256 KB |
02-24.txt | RE | 114 ms | 256 KB |
02-25.txt | RE | 112 ms | 256 KB |
02-26.txt | RE | 112 ms | 256 KB |
02-27.txt | RE | 113 ms | 256 KB |
02-28.txt | RE | 112 ms | 256 KB |
02-29.txt | RE | 112 ms | 256 KB |
02-30.txt | RE | 113 ms | 256 KB |
02-31.txt | RE | 114 ms | 256 KB |
02-32.txt | RE | 112 ms | 256 KB |
02-33.txt | RE | 115 ms | 256 KB |
02-34.txt | RE | 111 ms | 256 KB |
02-35.txt | RE | 113 ms | 256 KB |
02-36.txt | RE | 112 ms | 256 KB |
02-37.txt | RE | 113 ms | 256 KB |
02-38.txt | RE | 113 ms | 256 KB |
02-39.txt | RE | 112 ms | 256 KB |
02-40.txt | RE | 111 ms | 256 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | RE | 112 ms | 256 KB |
sample-03.txt | AC | 786 ms | 74448 KB |