Submission #4343689
Source Code Expand
import java.util.Scanner; class Main { static int[] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); dp = new int[n + 1]; dp[0] = 0; // 1円ずつ払う for (int i = 1; i < n + 1; i++) { dp[i] = dp[i - 1] + 1; } for (int six = 1; six <= n; six *= 6) { for (int j = 1; j < n + 1; j++) { if (j - six < 0) { continue; } dp[j] = Math.min(dp[j - six] + 1, dp[j]); } } for (int nine = 1; nine < n + 1; nine *= 9) { for (int j = 1; j < n + 1; j++) { if (j - nine < 0) { continue; } dp[j] = Math.min(dp[j - nine] + 1, dp[j]); } } System.out.println(dp[n]); sc.close(); } }
Submission Info
Submission Time | |
---|---|
Task | C - Strange Bank |
User | topaz13 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 968 Byte |
Status | AC |
Exec Time | 124 ms |
Memory | 22100 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 | 115 ms | 21972 KB |
02.txt | AC | 115 ms | 20052 KB |
03.txt | AC | 115 ms | 17876 KB |
04.txt | AC | 108 ms | 21332 KB |
05.txt | AC | 105 ms | 21460 KB |
06.txt | AC | 95 ms | 20564 KB |
07.txt | AC | 95 ms | 20052 KB |
08.txt | AC | 94 ms | 19540 KB |
09.txt | AC | 95 ms | 19156 KB |
10.txt | AC | 96 ms | 21460 KB |
11.txt | AC | 101 ms | 20052 KB |
12.txt | AC | 124 ms | 22100 KB |
13.txt | AC | 101 ms | 21204 KB |
14.txt | AC | 95 ms | 20820 KB |
15.txt | AC | 98 ms | 19284 KB |
16.txt | AC | 114 ms | 18892 KB |
sample_01.txt | AC | 96 ms | 19540 KB |
sample_02.txt | AC | 94 ms | 19796 KB |
sample_03.txt | AC | 117 ms | 21460 KB |