結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2015-11-28 09:49:44 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,230 bytes |
コンパイル時間 | 3,724 ms |
コンパイル使用メモリ | 77,904 KB |
実行使用メモリ | 58,668 KB |
最終ジャッジ日時 | 2024-10-06 18:44:57 |
合計ジャッジ時間 | 14,619 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 2 TLE * 1 -- * 32 |
ソースコード
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); char tmp; int countka = 0; int tututu = 0; for(int i=0;i<k;i++){ tututu = 0; tmp = soft.eat(); if(tmp == '1'){ if(k <= soft.getKazu()){ countka++; break; } tututu++; }else if(tmp == '2'){ if(k <= soft.getKazu()){ countka++; break; } tututu++; tututu++; } for(int j=0;j<tututu;j++){ tmp = soft.eat(); if(tmp == '1'){ if(k <= soft.getKazu()){ break; } tututu++; }else if(tmp == '2'){ if(k <= soft.getKazu()){ break; } tututu++; tututu++; } } 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; } }