結果

問題 No.78 クジ付きアイスバー
ユーザー holegumaholeguma
提出日時 2015-08-14 14:45:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 1,014 bytes
コンパイル時間 2,122 ms
コンパイル使用メモリ 77,392 KB
実行使用メモリ 50,596 KB
最終ジャッジ日時 2024-04-25 14:33:28
合計ジャッジ時間 5,377 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,036 KB
testcase_01 AC 52 ms
50,332 KB
testcase_02 AC 55 ms
50,328 KB
testcase_03 AC 53 ms
50,500 KB
testcase_04 AC 53 ms
49,948 KB
testcase_05 AC 54 ms
50,512 KB
testcase_06 AC 54 ms
50,320 KB
testcase_07 AC 52 ms
50,512 KB
testcase_08 AC 53 ms
50,256 KB
testcase_09 AC 54 ms
50,332 KB
testcase_10 AC 55 ms
50,256 KB
testcase_11 AC 54 ms
50,296 KB
testcase_12 AC 54 ms
50,536 KB
testcase_13 AC 53 ms
50,584 KB
testcase_14 AC 53 ms
50,388 KB
testcase_15 AC 53 ms
50,528 KB
testcase_16 AC 53 ms
50,272 KB
testcase_17 AC 55 ms
50,276 KB
testcase_18 AC 53 ms
50,420 KB
testcase_19 AC 53 ms
50,484 KB
testcase_20 AC 53 ms
50,532 KB
testcase_21 AC 54 ms
50,492 KB
testcase_22 AC 54 ms
50,440 KB
testcase_23 AC 53 ms
50,068 KB
testcase_24 AC 55 ms
50,216 KB
testcase_25 AC 55 ms
50,144 KB
testcase_26 AC 53 ms
50,352 KB
testcase_27 AC 53 ms
50,540 KB
testcase_28 AC 52 ms
50,464 KB
testcase_29 AC 55 ms
50,408 KB
testcase_30 AC 51 ms
50,520 KB
testcase_31 AC 54 ms
50,188 KB
testcase_32 AC 53 ms
50,596 KB
testcase_33 AC 53 ms
50,260 KB
testcase_34 AC 53 ms
50,220 KB
testcase_35 AC 53 ms
50,376 KB
testcase_36 AC 53 ms
50,572 KB
testcase_37 AC 52 ms
50,056 KB
testcase_38 AC 53 ms
50,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static int cnt;

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
StringTokenizer st= new StringTokenizer(line);
int n=Integer.parseInt(st.nextToken());
int k=Integer.parseInt(st.nextToken());
int[] ice=new int[n];
line=br.readLine();
int hitiol=0;
int hit=0;
long ans=0;
long cnt=0;
for(int i=0;i<n;i++){
ice[i]=line.charAt(i)-'0';
hitiol+=ice[i];
}
if(k<n){
for(int i=0;i<k;i++){
hit--;
if(hit<0){
ans++;
hit++;
}
hit+=ice[i];
}
out.println(ans);
}
else{
for(int i=0;i<n;i++){
hit--;
if(hit<0){
ans++;
hit++;
}
hit+=ice[i];
}
if(hitiol>=n){
out.println(ans);
}
else{
int loop=(int)k/n-1;
ans+=(n-hitiol)*loop;
int rest=k%n;
for(int i=0;i<rest;i++){
hit--;
if(hit<0){
ans++; hit++;
}
hit+=ice[i];
}
out.println(ans);
}
}
out.flush();
}
}
}
0