結果
問題 | No.78 クジ付きアイスバー |
ユーザー | uafr_cs |
提出日時 | 2015-06-17 01:07:10 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,318 bytes |
コンパイル時間 | 2,159 ms |
コンパイル使用メモリ | 78,448 KB |
実行使用メモリ | 81,616 KB |
最終ジャッジ日時 | 2024-04-16 05:01:24 |
合計ジャッジ時間 | 11,453 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 115 ms
40,372 KB |
testcase_02 | AC | 126 ms
41,136 KB |
testcase_03 | AC | 130 ms
40,820 KB |
testcase_04 | AC | 129 ms
41,200 KB |
testcase_05 | AC | 129 ms
41,252 KB |
testcase_06 | AC | 116 ms
40,080 KB |
testcase_07 | AC | 128 ms
41,312 KB |
testcase_08 | AC | 128 ms
41,440 KB |
testcase_09 | AC | 128 ms
40,980 KB |
testcase_10 | AC | 128 ms
41,328 KB |
testcase_11 | AC | 118 ms
40,352 KB |
testcase_12 | AC | 133 ms
41,148 KB |
testcase_13 | AC | 130 ms
41,284 KB |
testcase_14 | AC | 128 ms
41,308 KB |
testcase_15 | AC | 128 ms
41,444 KB |
testcase_16 | AC | 114 ms
40,348 KB |
testcase_17 | AC | 125 ms
41,328 KB |
testcase_18 | AC | 128 ms
41,424 KB |
testcase_19 | TLE | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
import java.math.BigDecimal; import java.util.Arrays; import java.util.Scanner; public class Main { public static long simulate(final int N, int[] S, long K, final long initial_bonus){ long bonus = initial_bonus; long cost = 0; for(long i = 0; i < K; i++){ final int index = (int)(i % N); if(bonus > 0){ bonus--; }else{ cost++; } bonus += S[index]; } return cost; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final long K = sc.nextLong(); char[] inputs = sc.next().toCharArray(); int[] S = new int[N]; for(int i = 0; i < N; i++){ S[i] = Character.getNumericValue(inputs[i]); } int one_cycle_cost = 0, one_cycle_bonus = 0; for(int i = 0; i < N; i++){ if(one_cycle_bonus > 0){ one_cycle_bonus--; }else{ one_cycle_cost++; } one_cycle_bonus += S[i]; } if(one_cycle_bonus > 0){ final int infinit_turns = (one_cycle_cost + one_cycle_bonus - 1) / one_cycle_bonus; final long infinite_N = infinit_turns * N; if(infinite_N <= N){ System.out.println(infinit_turns * one_cycle_cost); }else{ System.out.println(simulate(N, S, K, 0)); } }else{ System.out.println((K / N * one_cycle_cost) + simulate(N, S, K % N, 0)); } } }