結果

問題 No.78 クジ付きアイスバー
ユーザー kenji_shioya
提出日時 2016-07-08 16:59:04
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 773 bytes
コンパイル時間 3,854 ms
コンパイル使用メモリ 76,560 KB
実行使用メモリ 59,684 KB
最終ジャッジ日時 2024-10-12 23:28:02
合計ジャッジ時間 11,488 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 TLE * 1 -- * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise148{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();
    String s = sc.next();
    String sumS = s;
    if(k > n){
      for(int i = 1; i < (int)Math.ceil((double)k / (double)n); i++){
        sumS += s;
      }
    }
    long p = 0;
    long g = 0;
    char[] sArray = sumS.toCharArray();
    for(int i = 0; i < k; i++){
      if(g > 0){
        if(c(sArray[i]) > 0){
          g += c(sArray[i]);
        }
        g--;
      }else{
        if(c(sArray[i]) > 0){
          g += c(sArray[i]);
        }
        p++;
      }
    }
    System.out.println(p);
  }
  private static int c(char ch){
    return Character.getNumericValue(ch);
  }
}
0