結果
問題 | No.5018 Let's Make a Best-seller Book |
ユーザー | EvbCFfp1XB |
提出日時 | 2023-10-01 15:57:53 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 277 ms / 400 ms |
コード長 | 4,371 bytes |
コンパイル時間 | 2,752 ms |
コンパイル使用メモリ | 87,256 KB |
実行使用メモリ | 76,792 KB |
スコア | 10,882 |
平均クエリ数 | 52.00 |
最終ジャッジ日時 | 2023-10-01 15:58:26 |
合計ジャッジ時間 | 33,065 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 249 ms
74,448 KB |
testcase_01 | AC | 271 ms
75,004 KB |
testcase_02 | AC | 261 ms
75,208 KB |
testcase_03 | AC | 242 ms
73,868 KB |
testcase_04 | AC | 246 ms
74,688 KB |
testcase_05 | AC | 271 ms
74,992 KB |
testcase_06 | AC | 239 ms
74,544 KB |
testcase_07 | AC | 242 ms
75,336 KB |
testcase_08 | AC | 241 ms
75,012 KB |
testcase_09 | AC | 239 ms
74,840 KB |
testcase_10 | AC | 245 ms
74,908 KB |
testcase_11 | AC | 242 ms
74,840 KB |
testcase_12 | AC | 247 ms
75,292 KB |
testcase_13 | AC | 242 ms
74,588 KB |
testcase_14 | AC | 240 ms
74,596 KB |
testcase_15 | AC | 240 ms
75,100 KB |
testcase_16 | AC | 240 ms
74,880 KB |
testcase_17 | AC | 239 ms
74,684 KB |
testcase_18 | AC | 247 ms
74,820 KB |
testcase_19 | AC | 241 ms
74,996 KB |
testcase_20 | AC | 242 ms
75,380 KB |
testcase_21 | AC | 245 ms
74,808 KB |
testcase_22 | AC | 243 ms
74,100 KB |
testcase_23 | AC | 262 ms
75,000 KB |
testcase_24 | AC | 234 ms
74,644 KB |
testcase_25 | AC | 240 ms
74,964 KB |
testcase_26 | AC | 252 ms
74,804 KB |
testcase_27 | AC | 269 ms
74,968 KB |
testcase_28 | AC | 245 ms
74,892 KB |
testcase_29 | AC | 243 ms
73,372 KB |
testcase_30 | AC | 239 ms
74,796 KB |
testcase_31 | AC | 262 ms
75,236 KB |
testcase_32 | AC | 240 ms
74,732 KB |
testcase_33 | AC | 238 ms
74,732 KB |
testcase_34 | AC | 239 ms
74,204 KB |
testcase_35 | AC | 241 ms
75,384 KB |
testcase_36 | AC | 237 ms
74,260 KB |
testcase_37 | AC | 240 ms
74,816 KB |
testcase_38 | AC | 238 ms
75,704 KB |
testcase_39 | AC | 241 ms
74,776 KB |
testcase_40 | AC | 263 ms
74,772 KB |
testcase_41 | AC | 236 ms
74,704 KB |
testcase_42 | AC | 239 ms
74,760 KB |
testcase_43 | AC | 236 ms
76,792 KB |
testcase_44 | AC | 277 ms
74,488 KB |
testcase_45 | AC | 248 ms
74,484 KB |
testcase_46 | AC | 244 ms
75,388 KB |
testcase_47 | AC | 236 ms
74,072 KB |
testcase_48 | AC | 245 ms
75,012 KB |
testcase_49 | AC | 243 ms
74,608 KB |
testcase_50 | AC | 239 ms
74,808 KB |
testcase_51 | AC | 242 ms
75,392 KB |
testcase_52 | AC | 239 ms
75,392 KB |
testcase_53 | AC | 240 ms
74,628 KB |
testcase_54 | AC | 244 ms
75,132 KB |
testcase_55 | AC | 241 ms
74,344 KB |
testcase_56 | AC | 244 ms
74,864 KB |
testcase_57 | AC | 243 ms
74,948 KB |
testcase_58 | AC | 242 ms
74,916 KB |
testcase_59 | AC | 239 ms
74,920 KB |
testcase_60 | AC | 233 ms
75,024 KB |
testcase_61 | AC | 253 ms
75,580 KB |
testcase_62 | AC | 242 ms
74,652 KB |
testcase_63 | AC | 238 ms
74,696 KB |
testcase_64 | AC | 244 ms
75,256 KB |
testcase_65 | AC | 243 ms
74,516 KB |
testcase_66 | AC | 241 ms
74,468 KB |
testcase_67 | AC | 241 ms
74,440 KB |
testcase_68 | AC | 241 ms
73,092 KB |
testcase_69 | AC | 248 ms
74,660 KB |
testcase_70 | AC | 245 ms
74,808 KB |
testcase_71 | AC | 243 ms
75,064 KB |
testcase_72 | AC | 246 ms
74,812 KB |
testcase_73 | AC | 249 ms
74,308 KB |
testcase_74 | AC | 243 ms
74,692 KB |
testcase_75 | AC | 241 ms
75,156 KB |
testcase_76 | AC | 246 ms
73,432 KB |
testcase_77 | AC | 244 ms
75,160 KB |
testcase_78 | AC | 272 ms
75,216 KB |
testcase_79 | AC | 243 ms
74,816 KB |
testcase_80 | AC | 245 ms
74,644 KB |
testcase_81 | AC | 243 ms
74,564 KB |
testcase_82 | AC | 269 ms
74,204 KB |
testcase_83 | AC | 244 ms
74,368 KB |
testcase_84 | AC | 244 ms
74,952 KB |
testcase_85 | AC | 243 ms
74,528 KB |
testcase_86 | AC | 246 ms
75,244 KB |
testcase_87 | AC | 245 ms
75,060 KB |
testcase_88 | AC | 244 ms
74,492 KB |
testcase_89 | AC | 243 ms
74,820 KB |
testcase_90 | AC | 249 ms
75,336 KB |
testcase_91 | AC | 247 ms
74,824 KB |
testcase_92 | AC | 247 ms
75,028 KB |
testcase_93 | AC | 247 ms
74,680 KB |
testcase_94 | AC | 246 ms
75,232 KB |
testcase_95 | AC | 250 ms
74,664 KB |
testcase_96 | AC | 243 ms
74,548 KB |
testcase_97 | AC | 236 ms
74,728 KB |
testcase_98 | AC | 235 ms
74,648 KB |
testcase_99 | AC | 264 ms
75,008 KB |
ソースコード
import java.util.Arrays; import java.util.Scanner; import java.util.SplittableRandom; import java.util.stream.IntStream; public class Main { public static void main(String[] args) throws Exception { new Main().run(); } private void run() { try (final Scanner in = new Scanner(System.in)) { int T = in.nextInt(); int N = in.nextInt(); int Money = in.nextInt(); SplittableRandom rng = new SplittableRandom(System.nanoTime()); double[][] rand = new double[T][N]; for (int t = 0; t < T; t++) { for (int n = 0; n < N; n++) { rand[t][n] = 1;// 0.75 + 0.5 * rng.nextDouble(); } } double[] D = IntStream.range(0, N).mapToDouble(i -> 1.0).toArray(); double[] minD = IntStream.range(0, N).mapToDouble(i -> 0.5).toArray(); double[] maxD = IntStream.range(0, N).mapToDouble(i -> 1.5).toArray(); int[] sumS = IntStream.range(0, N).map(i -> 0).toArray(); int[] S = IntStream.range(0, N).map(i -> 0).toArray(); int[] P = IntStream.range(0, N).map(i -> 0).toArray(); int[] R = IntStream.range(0, N).map(i -> 0).toArray(); for (int t = 0; t < T; t++) { if (t == 0) { // cm(2); book(N, rand, D, P, R, t, Money); } else if (t % 2 == 1) { int y = 0; for (int x = 1; x <= 5; x++) { if (500000 * (1 << (x - 1)) <= Money) { y = x; } } if (y == 0) { book(N, rand, D, P, R, t, Money); } else { cm(y); } } else { book(N, rand, D, P, R, t, Money); } Money = in.nextInt(); if (Money < 0) { return; } S = IntStream.range(0, N).map(i -> in.nextInt()).toArray(); for (int n = 0; n < N; n++) { sumS[n] += S[n]; } for (int n = 0; n < N; n++) { if (R[n] == 0) { continue; } minD[n] = Math.max(minD[n], (S[n] + 0.000000) / (Math.pow(R[n], 0.5) * Math.pow(1.05, P[n]) * 1.25)); maxD[n] = Math.min(maxD[n], (S[n] + 0.999999) / (Math.pow(R[n], 0.5) * Math.pow(1.05, P[n]) * 0.75)); D[n] = (minD[n] + maxD[n]) * 0.5; } P = IntStream.range(0, N).map(i -> in.nextInt()).toArray(); R = IntStream.range(0, N).map(i -> in.nextInt()).toArray(); Utils.debug("Money", Money); Utils.debug("S", S); Utils.debug("P", P); Utils.debug("R", R); Utils.debug("minD", minD); Utils.debug("maxD", maxD); Utils.debug(" D", D); } } catch (Exception e) { e.printStackTrace(); } } private void cm(int y) { StringBuilder sb = new StringBuilder(); sb.append(2); sb.append(" "); sb.append(y); System.out.println(sb.toString()); System.out.flush(); } private void book(int N, double[][] rand, double[] D, int[] P, int[] R, int t, int Money) { int targetBooks = 10; int[] copies = new int[N]; for (int n = 0; n < N; n++) { copies[n] = numberCopiesSoldInWeek(D[n], P[n], R[n], rand[t][n]); } StringBuilder sb = new StringBuilder(); sb.append(1); for (int n = 0; n < N; n++) { sb.append(" "); if (P[n] >= 30) { targetBooks += P[n] * 3; int books = Math.max(0, targetBooks - (R[n] - copies[n])); if (Money >= 500 * books) { sb.append(books); Money -= 500 * books; } else { sb.append(0); } } else if (P[n] >= 10) { targetBooks += P[n] * 1.5; int books = Math.max(0, targetBooks - (R[n] - copies[n])); if (Money >= 500 * books) { sb.append(books); Money -= 500 * books; } else { sb.append(0); } } else if (R[n] - copies[n] < targetBooks) { int books = Math.max(0, targetBooks - (R[n] - copies[n])); if (Money >= 500 * books) { sb.append(books); Money -= 500 * books; } else { sb.append(0); } } else { sb.append(0); } // if (copies[n] > R[n]) { // sb.append(copies[n] - R[n]); // } else { // sb.append(0); // } } System.out.println(sb.toString()); System.out.flush(); } private int numberCopiesSoldInWeek(double D, int P, int R, double rand) { return (int) Math.min(R, Math.pow(R, 0.5) * Math.pow(1.05, P) * D * rand); } } class Utils { private Utils() { } public static final void debug(Object... o) { // System.err.println(toString(o)); // System.err.flush(); } public static final String toString(Object... o) { return Arrays.deepToString(o); } public static boolean isValid(int v, int min, int minUpper) { return v >= min && v < minUpper; } }