結果

問題 No.78 クジ付きアイスバー
ユーザー ルッツファンルッツファン
提出日時 2015-11-28 09:49:44
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,230 bytes
コンパイル時間 3,704 ms
コンパイル使用メモリ 77,828 KB
実行使用メモリ 102,104 KB
最終ジャッジ日時 2024-04-16 05:54:24
合計ジャッジ時間 14,329 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
102,104 KB
testcase_01 AC 55 ms
50,160 KB
testcase_02 AC 56 ms
50,160 KB
testcase_03 AC 54 ms
50,192 KB
testcase_04 AC 55 ms
50,268 KB
testcase_05 AC 4,080 ms
51,508 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
	}
	
	
}
0