結果
問題 | No.154 市バス |
ユーザー | yun_app |
提出日時 | 2016-06-11 00:59:09 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 210 ms / 2,000 ms |
コード長 | 1,271 bytes |
コンパイル時間 | 1,925 ms |
コンパイル使用メモリ | 76,884 KB |
実行使用メモリ | 41,668 KB |
最終ジャッジ日時 | 2024-04-21 09:32:11 |
合計ジャッジ時間 | 4,120 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 209 ms
41,668 KB |
testcase_01 | AC | 207 ms
41,380 KB |
testcase_02 | AC | 210 ms
41,432 KB |
testcase_03 | AC | 203 ms
41,500 KB |
testcase_04 | AC | 200 ms
41,348 KB |
testcase_05 | AC | 45 ms
36,624 KB |
testcase_06 | AC | 47 ms
37,032 KB |
testcase_07 | AC | 195 ms
41,320 KB |
testcase_08 | AC | 45 ms
36,900 KB |
ソースコード
import java.util.*; import java.lang.*; import java.io.*; class Ideone{ public static void main(String[] args) throws Exception{ // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); start:for(int i=0;i<n;i++){ String str = br.readLine(); int bus = 0; int r = 0; int w = 0; for(int j=str.length()-1;j>=0;j--){ char c = str.charAt(j); if(c=='W'){ if(bus==0){ System.out.println("impossible"); continue start; } if(bus>w) w++; }else if(c=='R'){ r++; }else if(c=='G'){ if(r==0){ System.out.println("impossible"); continue start; } r--; bus++; } } if(r==0 && w>=bus) System.out.println("possible"); else System.out.println("impossible"); } } }