結果

問題 No.154 市バス
ユーザー htensaihtensai
提出日時 2019-12-26 13:01:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 74,532 KB
実行使用メモリ 59,504 KB
最終ジャッジ日時 2024-04-14 11:26:07
合計ジャッジ時間 6,616 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 376 ms
57,560 KB
testcase_01 AC 360 ms
58,780 KB
testcase_02 AC 354 ms
58,608 KB
testcase_03 AC 406 ms
59,504 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 353 ms
57,952 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char[] arr = sc.next().toCharArray();
            int count = 0;
            for (char c : arr) {
                if (c == 'G') {
                    count++;
                } else if(c == 'R') {
                    count--;
                }
                if (count < 0) {
                    break;
                }
            }
            if (count != 0) {
                sb.append("impossible");
            } else {
                sb.append("possible");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}
0