結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2015-11-28 09:31:28 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,923 bytes |
コンパイル時間 | 3,605 ms |
コンパイル使用メモリ | 77,252 KB |
実行使用メモリ | 785,880 KB |
最終ジャッジ日時 | 2024-10-06 18:36:15 |
合計ジャッジ時間 | 31,124 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 MLE * 14 -- * 19 |
ソースコード
package yukicoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class yukicoder015 { public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String tes = null; try { tes = br.readLine(); } catch (IOException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } String[] sp = tes.split(" "); int n = Integer.parseInt(sp[0]); int k = Integer.parseInt(sp[1]); try { tes = br.readLine(); } catch (IOException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } aisu soft = new aisu(tes); String lol = tes; char tmp; int countka = 0; for(int i=0;i<k;i++){ tmp = soft.eat(); if(tmp == '1'){ if(k <= soft.getKazu()){ break; } kkk(soft,1,k); }else if(tmp == '2'){ if(k <= soft.getKazu()){ break; } kkk(soft,2,k); } countka++; if(k <= soft.getKazu()){ break; } } System.out.println(countka); } private static void kkk(aisu soft, int tugi,int k) { int tmp; for(int i=0;i<tugi;i++){ tmp = soft.eat(); if(tmp == '1'){ if(k <= soft.getKazu()){ return; } kkk(soft,1,k); }else if(tmp == '2'){ if(k <= soft.getKazu()){ return; } kkk(soft,2,k); } } } } class aisu{ private String hako; private int basyo =0; private int max; private int kazu = 0; public aisu(String tmp){ hako = tmp; max = hako.length(); } public char eat(){ char ret; ret = hako.charAt(basyo); ink(); kazu++; return ret; } private void ink(){ basyo++; basyo = basyo % max; } public String getHako() { return hako; } public int getBasyo() { return basyo; } public int getMax() { return max; } public int getKazu() { return kazu; } }