結果

問題 No.154 市バス
ユーザー AreTrashAreTrash
提出日時 2016-04-28 15:20:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 955 ms
コンパイル使用メモリ 109,892 KB
実行使用メモリ 30,708 KB
最終ジャッジ日時 2024-04-21 09:27:31
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
30,436 KB
testcase_01 AC 50 ms
28,256 KB
testcase_02 AC 51 ms
28,388 KB
testcase_03 AC 47 ms
28,384 KB
testcase_04 WA -
testcase_05 AC 27 ms
24,612 KB
testcase_06 AC 27 ms
26,208 KB
testcase_07 AC 46 ms
30,460 KB
testcase_08 AC 26 ms
24,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

namespace No154_1{
    public class Program{
        public static void Main(string[] args){
            Console.ReadLine();
            string str;
            while((str = Console.ReadLine()) != null){
                int cntW = 0, cntG = 0, cntR = 0;
                var possible = true;

                foreach(var c in str){
                    if(c == 'W') cntW++;
                    if(c == 'G') cntG++;
                    if(c == 'R') cntR++;
                    if(cntG < cntR) possible = false;
                }

                if(cntW < cntG || cntG != cntR || str.Skip(str.LastIndexOf('G') + 1).Any(c => c == 'W'))
                    possible = false;

                Console.WriteLine((possible ? "" : "im") + "possible");
            }
        }
    }
}
0