Submission #993423
Source Code Expand
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.InputMismatchException; import java.util.PriorityQueue; import java.util.TreeSet; public class Main { InputStream is; int __t__ = 1; int __f__ = 0; int __FILE_DEBUG_FLAG__ = __f__; String __DEBUG_FILE_NAME__ = "src/E3"; FastScanner in; PrintWriter out; int MAX = 1000000; long INF = 1000000000000L; public void solve() { long N = in.nextLong(), A = in.nextLong(); if (N > MAX || A > MAX) return; long[] dp = new long[(int)(N + N + 10)]; Arrays.fill(dp, INF); dp[0] = 0; dp[1] = 1; long res = Long.MAX_VALUE; for (int x = 1; x <= N; x++) { if (x != 1) dp[x] += A + 1; int cur = x; for (int i = 1; cur < N; cur += x, i++) { dp[cur+x] = Math.min(dp[cur+x], dp[x] + i); } res = Math.min(dp[cur], res); } System.out.println(res); /* long cur = 1; long total = 1; long x = 1; while (cur < N) { long a = A + 2; long b = cur / x; long a2 = A + (N + cur - 1) / cur; long b2 = (N - cur) / x; if (a <= b && a2 < b2) { x = cur; total += A + 1; } else { cur += x; total++; } } System.out.println(total); */ } public void run() { if (__FILE_DEBUG_FLAG__ == __t__) { try { is = new FileInputStream(__DEBUG_FILE_NAME__); } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println("FILE_INPUT!"); } else { is = System.in; } in = new FastScanner(is); out = new PrintWriter(System.out); Thread t = new Thread(null, new Runnable() { @Override public void run() { solve(); } }, "lul", 1 << 30); t.start(); } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------"); System.out.println(); } public void debug(Object... obj) { System.out.println(Arrays.deepToString(obj)); } class FastScanner { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FastScanner(InputStream stream) { this.stream = stream; //stream = new FileInputStream(new File("dec.in")); } int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } int[][] nextIntMap(int n, int m) { int[][] map = new int[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextIntArray(m); } return map; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } long[][] nextLongMap(int n, int m) { long[][] map = new long[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextLongArray(m); } return map; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } double[][] nextDoubleMap(int n, int m) { double[][] map = new double[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextDoubleArray(m); } return map; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }
Submission Info
Submission Time | |
---|---|
Task | E - Cookies |
User | hiro116s |
Language | Java8 (OpenJDK 1.8.0) |
Score | 500 |
Code Size | 5089 Byte |
Status | WA |
Exec Time | 183 ms |
Memory | 24308 KB |
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 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 | AC | 181 ms | 24144 KB |
01-02.txt | AC | 183 ms | 24308 KB |
01-03.txt | AC | 183 ms | 24180 KB |
01-04.txt | AC | 182 ms | 24180 KB |
01-05.txt | AC | 180 ms | 24308 KB |
01-06.txt | AC | 183 ms | 24180 KB |
01-07.txt | AC | 179 ms | 24148 KB |
01-08.txt | AC | 180 ms | 24144 KB |
01-09.txt | AC | 181 ms | 24184 KB |
01-10.txt | AC | 180 ms | 24148 KB |
01-11.txt | AC | 179 ms | 24052 KB |
01-12.txt | AC | 179 ms | 24184 KB |
01-13.txt | AC | 182 ms | 24180 KB |
01-14.txt | AC | 116 ms | 9428 KB |
01-15.txt | AC | 144 ms | 16724 KB |
01-16.txt | AC | 142 ms | 16632 KB |
01-17.txt | AC | 181 ms | 23924 KB |
01-18.txt | AC | 90 ms | 8436 KB |
01-19.txt | AC | 89 ms | 8312 KB |
01-20.txt | AC | 90 ms | 8400 KB |
01-21.txt | AC | 90 ms | 8436 KB |
01-22.txt | AC | 88 ms | 8404 KB |
01-23.txt | AC | 90 ms | 8396 KB |
01-24.txt | AC | 90 ms | 8308 KB |
01-25.txt | AC | 90 ms | 8312 KB |
01-26.txt | AC | 90 ms | 8308 KB |
02-01.txt | WA | 89 ms | 8276 KB |
02-02.txt | WA | 89 ms | 8400 KB |
02-03.txt | WA | 89 ms | 8308 KB |
02-04.txt | WA | 89 ms | 8396 KB |
02-05.txt | WA | 89 ms | 8404 KB |
02-06.txt | WA | 88 ms | 8308 KB |
02-07.txt | WA | 89 ms | 8328 KB |
02-08.txt | WA | 88 ms | 8332 KB |
02-09.txt | WA | 88 ms | 8272 KB |
02-10.txt | WA | 89 ms | 8400 KB |
02-11.txt | WA | 89 ms | 8404 KB |
02-12.txt | WA | 89 ms | 8400 KB |
02-13.txt | WA | 90 ms | 8396 KB |
02-14.txt | WA | 89 ms | 8404 KB |
02-15.txt | WA | 89 ms | 8396 KB |
02-16.txt | WA | 89 ms | 8396 KB |
02-17.txt | WA | 89 ms | 8276 KB |
02-18.txt | WA | 90 ms | 8392 KB |
02-19.txt | WA | 89 ms | 8276 KB |
02-20.txt | WA | 89 ms | 8272 KB |
02-21.txt | WA | 88 ms | 8276 KB |
02-22.txt | WA | 89 ms | 8324 KB |
02-23.txt | WA | 89 ms | 8272 KB |
02-24.txt | WA | 87 ms | 8308 KB |
02-25.txt | WA | 89 ms | 8328 KB |
02-26.txt | WA | 89 ms | 8328 KB |
02-27.txt | WA | 88 ms | 8312 KB |
02-28.txt | WA | 88 ms | 8400 KB |
02-29.txt | WA | 88 ms | 8404 KB |
02-30.txt | WA | 88 ms | 8312 KB |
02-31.txt | WA | 88 ms | 8312 KB |
02-32.txt | WA | 89 ms | 8336 KB |
02-33.txt | WA | 89 ms | 8404 KB |
02-34.txt | WA | 89 ms | 8272 KB |
02-35.txt | WA | 89 ms | 8400 KB |
02-36.txt | WA | 87 ms | 8308 KB |
02-37.txt | WA | 88 ms | 8332 KB |
02-38.txt | WA | 89 ms | 8400 KB |
02-39.txt | WA | 89 ms | 8400 KB |
02-40.txt | WA | 89 ms | 8396 KB |
sample-01.txt | AC | 90 ms | 8436 KB |
sample-02.txt | WA | 89 ms | 8336 KB |
sample-03.txt | AC | 110 ms | 10484 KB |