結果

問題 No.78 クジ付きアイスバー
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-24 23:55:20
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 720 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 75,092 KB
実行使用メモリ 41,676 KB
最終ジャッジ日時 2024-04-16 05:03:34
合計ジャッジ時間 78,993 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,120 KB
testcase_01 AC 129 ms
41,328 KB
testcase_02 AC 118 ms
40,320 KB
testcase_03 AC 118 ms
40,076 KB
testcase_04 AC 131 ms
41,160 KB
testcase_05 AC 1,159 ms
41,636 KB
testcase_06 AC 2,874 ms
41,252 KB
testcase_07 AC 1,100 ms
41,052 KB
testcase_08 AC 1,608 ms
41,616 KB
testcase_09 TLE -
testcase_10 AC 3,353 ms
41,676 KB
testcase_11 AC 1,583 ms
41,228 KB
testcase_12 AC 2,869 ms
41,476 KB
testcase_13 AC 3,221 ms
41,460 KB
testcase_14 TLE -
testcase_15 AC 2,070 ms
41,384 KB
testcase_16 AC 2,224 ms
41,304 KB
testcase_17 AC 2,692 ms
40,416 KB
testcase_18 AC 3,966 ms
41,504 KB
testcase_19 AC 4,734 ms
41,552 KB
testcase_20 AC 3,848 ms
41,192 KB
testcase_21 TLE -
testcase_22 AC 4,458 ms
40,112 KB
testcase_23 AC 128 ms
41,080 KB
testcase_24 AC 130 ms
41,504 KB
testcase_25 AC 131 ms
41,604 KB
testcase_26 AC 131 ms
41,532 KB
testcase_27 AC 133 ms
40,988 KB
testcase_28 AC 132 ms
41,304 KB
testcase_29 AC 129 ms
41,472 KB
testcase_30 AC 133 ms
41,400 KB
testcase_31 AC 130 ms
41,520 KB
testcase_32 AC 129 ms
41,236 KB
testcase_33 AC 142 ms
41,128 KB
testcase_34 AC 1,368 ms
41,636 KB
testcase_35 AC 1,604 ms
41,356 KB
testcase_36 AC 4,384 ms
40,992 KB
testcase_37 TLE -
testcase_38 AC 2,760 ms
40,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;


public class Main {
	static int N, K;
	static String S;
			
	static private void solve()
	{
		int buybar = 0;
		int nextbar = 0;
		int freebar = 0;
		
		for (int k = 1; k <= K; k++) {
			if (freebar > 0) 
				freebar--;
			else 
				buybar++;
			
			switch (S.charAt(nextbar)) {
			case '0': break;
			case '1': freebar++;  break;
			case '2': freebar+=2; break;
			}
			
			nextbar++;
			if (nextbar == N) {
				nextbar = 0;
			}
		}
		
		System.out.println(buybar);
	}
	
	static public void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		N = sca.nextInt();
		K = sca.nextInt();
		S = sca.next();
		
		solve();
	}
}
0