結果

問題 No.145 yukiover
ユーザー 14番14番
提出日時 2016-07-20 07:35:36
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,474 bytes
コンパイル時間 1,067 ms
コンパイル使用メモリ 109,824 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-04-23 16:59:01
合計ジャッジ時間 3,045 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
19,328 KB
testcase_01 AC 31 ms
19,200 KB
testcase_02 AC 30 ms
19,200 KB
testcase_03 AC 38 ms
19,328 KB
testcase_04 AC 29 ms
19,200 KB
testcase_05 AC 34 ms
19,456 KB
testcase_06 AC 37 ms
19,328 KB
testcase_07 AC 37 ms
19,456 KB
testcase_08 WA -
testcase_09 AC 30 ms
19,072 KB
testcase_10 WA -
testcase_11 AC 37 ms
19,584 KB
testcase_12 AC 53 ms
20,992 KB
testcase_13 AC 57 ms
20,864 KB
testcase_14 AC 63 ms
20,736 KB
testcase_15 WA -
testcase_16 AC 34 ms
19,328 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 61 ms
21,888 KB
testcase_20 AC 60 ms
21,632 KB
testcase_21 WA -
testcase_22 AC 62 ms
21,888 KB
testcase_23 AC 48 ms
20,224 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.Collections.Generic;
using System.Text;
using System.Linq;



class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int panelCount = int.Parse(Reader.ReadLine());
        string inpt = Reader.ReadLine();

        char[] big = inpt.Where(a=>a>'y').ToArray();
        char[] nokori = inpt.Where(a=>a<='y').ToArray();
        int ans = this.getAns(nokori) + big.Length;
        Console.WriteLine(ans);
    }

    private int getAns(char[] nokori) {
        int ans = 0;
        char[] y = nokori.Where(a=>a == 'y').ToArray();
        char[] other = nokori.Where(a=>a!='y').ToArray();

        if(other.Count(a=>a > 'u') > 0) {
            char[] uOver = other.Where(a=>a>'u').OrderBy(a=>a).ToArray();
            other = other.Where(a=>a<='u').ToArray();
            if(uOver.Length >= y.Length) {
                return y.Length;
            } else {
                ans = uOver.Length;
                y = y.Skip(uOver.Length).ToArray();
            }
        }
        if(y.Length == 0) {
            return ans;
        }
        if(other.Count(a=>a=='u') > 0) {
            char[] u = other.Where(a=>a=='u').ToArray();
            other = other.Where(a=>a!='u').ToArray();
            if(u.Length > y.Length) {
                u = u.Skip(y.Length).ToArray();
                other = other.Concat(u).ToArray();
            } else if(u.Length < y.Length) {
                other = other.Concat(y.Skip(u.Length)).ToArray();
                y = y.Take(u.Length).ToArray();
            }
        } else {
            y = new char[0];
        }
        if(y.Length == 0) {
            return ans;
        }
        if(other.Count(a=>a>'k') > 0) {
            char[] kOver = other.Where(a=>a>'k').OrderBy(a=>a).ToArray();
            other = other.Where(a=>a <= 'k').ToArray();
            if(kOver.Length >= y.Length) {
                ans += y.Length;
                return ans;
            } else {
                ans += kOver.Length;
                y = y.Skip(kOver.Length).ToArray();
            }
        }
        if(other.Count(a=>a=='k') > 0) {
            char[] k = other.Where(a=>a=='k').ToArray();
            other = other.Where(a=>a!='k').ToArray();

            if(k.Length > y.Length) {
                k = k.Skip(y.Length).ToArray();
                other = other.Concat(k).ToArray();
            } else if(k.Length < y.Length) {
                other = other.Concat(y.Skip(k.Length)).ToArray();
                y = y.Take(k.Length).ToArray();
            }
        } else {
            y = new char[0];
        }
        if(y.Length == 0) {
            return ans;
        }
        if(other.Count(a=>a>'i') > 0) {
            char[] iOver = other.Where(a=>a>'i').OrderBy(a=>a).ToArray();
            other = other.Where(a=>a<='i').ToArray();
            if(iOver.Length < y.Length) {
                ans+=iOver.Length;
                y = y.Skip(iOver.Length).ToArray();
            } else {
                ans+=y.Length;
                return ans;
            }
        }
        if(other.Count(a=>a=='i') > 0) {
            char[] i = other.Where(a=>a=='i').ToArray();
            other = other.Where(a=>a != 'i').ToArray();
            if(i.Length > y.Length) {
                i = i.Skip(y.Length).ToArray();
                other = other.Concat(i).ToArray();
            } else if(i.Length < y.Length) {
                other = other.Concat(y.Skip(i.Length)).ToArray();
                y = y.Take(i.Length).ToArray();
            }
        } else {
            y = new char[0];
        }
        if(y.Length == 0) {
            return ans;
        }
        
        if(other.Length > y.Length) {
            ans += y.Length;
        } else {
            ans += other.Length;
        }
        return ans;
    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

11
kyuukyuusya


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0