結果
問題 | No.78 クジ付きアイスバー |
ユーザー |
![]() |
提出日時 | 2016-05-11 17:16:05 |
言語 | Java (openjdk 23) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 914 bytes |
コンパイル時間 | 2,087 ms |
コンパイル使用メモリ | 75,088 KB |
実行使用メモリ | 41,296 KB |
最終ジャッジ日時 | 2024-10-06 19:19:21 |
合計ジャッジ時間 | 54,516 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 34 TLE * 1 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner scan = new Scanner(System.in)) { int n = Integer.parseInt(scan.next()); int k = Integer.parseInt(scan.next()); String s = scan.next(); int buy = 0; int stack = 0; int sum = 0; int index = 0; while(true) { if(stack == 0) { buy++; sum++; } else { stack--; } int now = s.charAt(index) - '0'; stack += now; sum += now; if(++index == s.length()) index = 0; if(sum >= k) break; } System.out.println(buy); } } }