結果

問題 No.78 クジ付きアイスバー
ユーザー chocoruskchocorusk
提出日時 2020-10-03 10:44:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,004 bytes
コンパイル時間 2,604 ms
コンパイル使用メモリ 73,888 KB
実行使用メモリ 57,640 KB
最終ジャッジ日時 2023-09-25 04:55:33
合計ジャッジ時間 9,345 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,632 KB
testcase_01 AC 121 ms
55,832 KB
testcase_02 AC 119 ms
56,308 KB
testcase_03 AC 121 ms
55,816 KB
testcase_04 AC 118 ms
56,056 KB
testcase_05 WA -
testcase_06 AC 120 ms
56,036 KB
testcase_07 WA -
testcase_08 AC 119 ms
55,784 KB
testcase_09 AC 122 ms
55,804 KB
testcase_10 AC 124 ms
55,688 KB
testcase_11 AC 118 ms
55,776 KB
testcase_12 WA -
testcase_13 AC 118 ms
56,256 KB
testcase_14 AC 121 ms
56,060 KB
testcase_15 AC 119 ms
55,672 KB
testcase_16 AC 120 ms
55,692 KB
testcase_17 AC 123 ms
55,492 KB
testcase_18 AC 118 ms
55,332 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 120 ms
56,048 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 120 ms
55,708 KB
testcase_30 AC 120 ms
55,868 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 120 ms
53,632 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 120 ms
55,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Integer.parseInt(scanner.next());
		long k=Long.parseLong(scanner.next());
		String s=scanner.next();
		long[][] nx=new long[32][51];
		final long INF=(long)1e12;
		for(int i=0; i<n; i++) {
			int sum=0;
			for(int j=i; j<i+n; j++) {
				int x=s.charAt(j%n)-'0';
				sum+=x;
				if(sum+1==j-i+1) {
					nx[0][i]=j+1;
					break;
				}
			}
			if(nx[0][i]==0) {
				nx[0][i]=INF;
			}
		}
		for(int i=1; i<=30; i++) {
			for(int j=0; j<n; j++) {
				long x=nx[i-1][j];
				if(x==INF) {
					nx[i][j]=INF;
				}else{
					nx[i][j]=Math.min(INF, x/n*n+nx[i-1][(int) (x%n)]);
				}
			}
		}
		long ans=0;
		int x=0;
		for(int i=30; i>=0; i--) {
			if(nx[i][x]<k) {
				ans+=(1<<i);
				x=(int)nx[i][x]%n;
				k-=nx[i][x]/n*n;
			}
		}
		out.println(ans+1);
		out.close();
		scanner.close();
	}
}
0