結果

問題 No.349 干支の置き物
ユーザー fkwnw3_1243
提出日時 2017-05-04 18:34:14
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 79,700 KB
実行使用メモリ 52,852 KB
最終ジャッジ日時 2024-09-14 07:11:18
合計ジャッジ時間 6,014 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int N = Integer.parseInt(reader.readLine());
        int countRequired = 0;
        String l = reader.readLine();
        for (int i = 1; i < N; i++) {
            String s = reader.readLine();
            if (l.equals(s)) {
                countRequired += 1;
            } else {
                if (countRequired > 0) {
                    countRequired -= 1;
                }
                l = s;
            }
            System.out.println(countRequired + " , current " + l);
        }
        if(countRequired>0){
            System.out.println("NO");
        } else{
            System.out.println("YES");
        }
    }
}
0