結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
ルッツファン
|
| 提出日時 | 2015-11-28 09:43:38 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,249 bytes |
| コンパイル時間 | 3,416 ms |
| コンパイル使用メモリ | 77,392 KB |
| 実行使用メモリ | 59,476 KB |
| 最終ジャッジ日時 | 2024-10-06 18:37:24 |
| 合計ジャッジ時間 | 14,371 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 1 WA * 1 TLE * 1 -- * 32 |
ソースコード
package yukicoder;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class yukicoder015 {
public static void main(String[] args){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String tes = null;
try {
tes = br.readLine();
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
String[] sp = tes.split(" ");
int n = Integer.parseInt(sp[0]);
int k = Integer.parseInt(sp[1]);
try {
tes = br.readLine();
} catch (IOException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
aisu soft = new aisu(tes);
char tmp;
int countka = 0;
int tututu = 0;
for(int i=0;i<k;i++){
tmp = soft.eat();
if(tmp == '1'){
if(k <= soft.getKazu()){
countka++;
break;
}
tututu++;
}else if(tmp == '2'){
if(k <= soft.getKazu()){
countka++;
break;
}
tututu++;
tututu++;
}
for(int j=0;j<tututu;j++){
tmp = soft.eat();
if(tmp == '1'){
if(k <= soft.getKazu()){
countka++;
break;
}
tututu++;
}else if(tmp == '2'){
if(k <= soft.getKazu()){
countka++;
break;
}
tututu++;
tututu++;
}
}
countka++;
if(k <= soft.getKazu()){
break;
}
}
System.out.println(countka);
}
private static void kkk(aisu soft, int tugi,int k) {
int tmp;
for(int i=0;i<tugi;i++){
tmp = soft.eat();
if(tmp == '1'){
if(k <= soft.getKazu()){
return;
}
kkk(soft,1,k);
}else if(tmp == '2'){
if(k <= soft.getKazu()){
return;
}
kkk(soft,2,k);
}
}
}
}
class aisu{
private String hako;
private int basyo =0;
private int max;
private int kazu = 0;
public aisu(String tmp){
hako = tmp;
max = hako.length();
}
public char eat(){
char ret;
ret = hako.charAt(basyo);
ink();
kazu++;
return ret;
}
private void ink(){
basyo++;
basyo = basyo % max;
}
public String getHako() {
return hako;
}
public int getBasyo() {
return basyo;
}
public int getMax() {
return max;
}
public int getKazu() {
return kazu;
}
}
ルッツファン