結果
問題 | No.78 クジ付きアイスバー |
ユーザー | ぴろず |
提出日時 | 2014-12-09 21:35:23 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 133 ms / 5,000 ms |
コード長 | 1,161 bytes |
コンパイル時間 | 7,561 ms |
コンパイル使用メモリ | 76,848 KB |
実行使用メモリ | 54,292 KB |
最終ジャッジ日時 | 2024-04-25 13:27:56 |
合計ジャッジ時間 | 8,780 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
53,904 KB |
testcase_01 | AC | 122 ms
53,900 KB |
testcase_02 | AC | 122 ms
53,712 KB |
testcase_03 | AC | 115 ms
53,724 KB |
testcase_04 | AC | 120 ms
53,948 KB |
testcase_05 | AC | 124 ms
54,088 KB |
testcase_06 | AC | 123 ms
53,628 KB |
testcase_07 | AC | 110 ms
52,812 KB |
testcase_08 | AC | 122 ms
53,724 KB |
testcase_09 | AC | 111 ms
53,088 KB |
testcase_10 | AC | 119 ms
54,292 KB |
testcase_11 | AC | 108 ms
53,068 KB |
testcase_12 | AC | 124 ms
54,012 KB |
testcase_13 | AC | 120 ms
54,080 KB |
testcase_14 | AC | 123 ms
53,896 KB |
testcase_15 | AC | 122 ms
53,916 KB |
testcase_16 | AC | 133 ms
54,008 KB |
testcase_17 | AC | 106 ms
52,988 KB |
testcase_18 | AC | 119 ms
54,136 KB |
testcase_19 | AC | 124 ms
53,972 KB |
testcase_20 | AC | 120 ms
53,828 KB |
testcase_21 | AC | 118 ms
54,252 KB |
testcase_22 | AC | 120 ms
54,168 KB |
testcase_23 | AC | 109 ms
52,972 KB |
testcase_24 | AC | 108 ms
52,972 KB |
testcase_25 | AC | 121 ms
54,056 KB |
testcase_26 | AC | 119 ms
54,048 KB |
testcase_27 | AC | 110 ms
52,732 KB |
testcase_28 | AC | 120 ms
53,880 KB |
testcase_29 | AC | 121 ms
54,212 KB |
testcase_30 | AC | 121 ms
53,856 KB |
testcase_31 | AC | 119 ms
54,120 KB |
testcase_32 | AC | 119 ms
54,240 KB |
testcase_33 | AC | 117 ms
54,160 KB |
testcase_34 | AC | 120 ms
53,836 KB |
testcase_35 | AC | 121 ms
53,964 KB |
testcase_36 | AC | 111 ms
52,952 KB |
testcase_37 | AC | 125 ms
53,996 KB |
testcase_38 | AC | 121 ms
54,104 KB |
ソースコード
package no078; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); char[] s = sc.next().toCharArray(); Pair[] bef = new Pair[n]; int bought = 0; int eaten = 0; int index = 0; boolean naive = false; while(true) { if (!naive && bef[index] != null) { int d = eaten - bef[index].eaten; int units = (k-eaten) / d; eaten += units * d; bought += units * (bought - bef[index].bought); naive = true; if (eaten >= k) { break; } } if (!naive) { bef[index] = new Pair(bought,eaten); } bought++; int atari = 1; for(int i=0;i<=n;i++) { atari--; eaten++; atari += s[index] - '0'; index = (index + 1) % n; if (atari == 0) { break; } if (i == n) { eaten = k; } } if (eaten >= k) { break; } } System.out.println(bought); } static class Pair { int bought,eaten; public Pair(int bought,int eaten) { this.bought = bought; this.eaten = eaten; } } }