Submission #3017214
Source Code Expand
#include <iostream> #include <vector> #include <unordered_map> #include <algorithm> //#include "../cxx-prettyprint/prettyprint.hpp" std::unordered_map<int, int> memo; int get_mininum_count(int N) { std::vector<int> withdrawals = {59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1}; if (N == 0) { return 0; } if (memo.count(N) == 1) { return memo[N]; } int min_count = N; for (int n : withdrawals) { if (n <= N) { min_count = std::min(min_count, get_mininum_count(N - n) + 1); } } memo[N] = min_count; return min_count; } int main() { int N; std::cin >> N; std::cout << get_mininum_count(N) << std::endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Strange Bank |
User | m_nakamoto |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 750 Byte |
Status | AC |
Exec Time | 76 ms |
Memory | 4388 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 31 ms | 2060 KB |
02.txt | AC | 76 ms | 4388 KB |
03.txt | AC | 26 ms | 1920 KB |
04.txt | AC | 42 ms | 2572 KB |
05.txt | AC | 33 ms | 2188 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 20 ms | 1408 KB |
12.txt | AC | 57 ms | 3620 KB |
13.txt | AC | 10 ms | 768 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 4 ms | 512 KB |
16.txt | AC | 76 ms | 4388 KB |
sample_01.txt | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 32 ms | 2188 KB |