結果

問題 No.154 市バス
ユーザー AreTrashAreTrash
提出日時 2016-04-28 15:29:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 808 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 113,480 KB
実行使用メモリ 22,528 KB
最終ジャッジ日時 2024-04-21 09:27:41
合計ジャッジ時間 1,899 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
22,272 KB
testcase_01 AC 49 ms
22,400 KB
testcase_02 AC 50 ms
22,528 KB
testcase_03 AC 46 ms
22,400 KB
testcase_04 AC 50 ms
22,400 KB
testcase_05 AC 25 ms
18,432 KB
testcase_06 AC 24 ms
18,432 KB
testcase_07 AC 44 ms
22,272 KB
testcase_08 AC 23 ms
18,304 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(cntW < cntG || cntG < cntR) possible = false;
                }

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

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