結果

問題 No.145 yukiover
ユーザー 14番14番
提出日時 2016-07-21 02:16:30
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 6,792 bytes
コンパイル時間 1,277 ms
コンパイル使用メモリ 116,668 KB
実行使用メモリ 70,356 KB
最終ジャッジ日時 2024-10-15 20:12:18
合計ジャッジ時間 9,126 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
19,840 KB
testcase_01 AC 36 ms
19,456 KB
testcase_02 AC 32 ms
19,456 KB
testcase_03 AC 43 ms
19,840 KB
testcase_04 AC 32 ms
19,584 KB
testcase_05 AC 40 ms
19,712 KB
testcase_06 AC 41 ms
19,840 KB
testcase_07 AC 42 ms
19,456 KB
testcase_08 AC 42 ms
19,584 KB
testcase_09 AC 32 ms
19,712 KB
testcase_10 WA -
testcase_11 AC 37 ms
20,352 KB
testcase_12 AC 62 ms
23,296 KB
testcase_13 AC 68 ms
23,808 KB
testcase_14 AC 74 ms
24,704 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Where(a=>a!='y').ToArray(), nokori.Where(a=>a=='y').ToArray()) + big.Length;
        Console.WriteLine(ans);
    }

    private int getAns(char[] nokori , char[] yList) {
        int ans = 0;
        List<string> target = new List<String>();
        yList.ToList().ForEach(a=>target.Add(a.ToString()));
        char[] other = nokori;
        if(target.Count == 0) {
            return ans;
        }

        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 >= target.Count) {
                return target.Count;
            } else {
                ans = uOver.Length;
                target = target.Skip(uOver.Length).ToList();
            }
        }
        if(target.Count == 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 > target.Count) {
                target = target.Select(a=>a + "u").ToList();
                u = u.Skip(target.Count).ToArray();
                other = other.Concat(u).ToArray();
            } else if(u.Length < target.Count) {
                other = other.Concat(target.Skip(u.Length).Select(a=>a[0])).ToArray();
                target = target.Take(u.Length).Select(a=>a + "u").ToList();
            }
        } else {
            if(target.Count >= 2) {
                target.ToList().ForEach(a=>other = other.Concat(a.ToArray()).ToArray());
                char[] newY = other.Where(a=>a == 'y').Take(target.Count - 1).ToArray();
                other = other.Where(a=>a!='y').Concat(new char[]{'y'}).ToArray();
                return ans + this.getAns(other, newY);
            } else {
                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 >= target.Count) {
                ans += target.Count;
                return ans;
            } else {
                ans += kOver.Length;
                target = target.Skip(kOver.Length).ToList();
            }
        }
        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 > target.Count) {
                k = k.Skip(target.Count).ToArray();
                other = other.Concat(k).ToArray();
                target = target.Select(a=>a + "k").ToList();
            } else if(k.Length < target.Count) {
                target.Skip(k.Length).ToList().ForEach(a=>other = other.Concat(a.ToArray()).ToArray());
                target = target.Take(k.Length).Select(a=>a + "k").ToList();
            }
        } else {
            if(target.Count >= 2) {
                target.ToList().ForEach(a=>other = other.Concat(a.ToArray()).ToArray());
                char[] newY = other.Where(a=>a == 'y').Take(target.Count - 1).ToArray();
                other = other.Where(a=>a!='y').Concat(new char[]{'y'}).ToArray();
                return ans + this.getAns(other, newY);
            } else {
                return ans;
            }
        }
        if(target.Count == 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 < target.Count) {
                ans+=iOver.Length;
                target = target.Skip(iOver.Length).ToList();
            } else {
                ans+=target.Count;
                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 > target.Count) {
                i = i.Skip(target.Count).ToArray();
                other = other.Concat(i).ToArray();
                target = target.Select(a=>a + "i").ToList();
            } else if(i.Length < target.Count) {
                target.Skip(i.Length).ToList().ForEach(a=>other = other.Concat(a.ToArray()).ToArray());
                target = target.Take(i.Length).Select(a=>a + "i").ToList();
            }
        } else {
            if(target.Count >= 2) {
                target.ToList().ForEach(a=>other = other.Concat(a.ToArray()).ToArray());
                char[] newY = other.Where(a=>a == 'y').Take(target.Count - 1).ToArray();
                other = other.Where(a=>a!='y').Concat(new char[]{'y'}).ToArray();
                return ans + this.getAns(other, newY);
            } else {
                return ans;
            }
        }
        if(target.Count > 0) {
            if(other.Length > target.Count) {
                ans += target.Count;
                other = other.OrderBy(a=>a).Skip(target.Count).ToArray();
                target.Clear();
            } else if(other.Length > 0) {
                ans += other.Length;
                target = target.Skip(other.Length).ToList();
                other = new char[0];
            }
        }

        if(target.Count > 0) {
            target.ForEach(a=>other = other.Concat(a.ToArray()).ToArray());
        }
        if(other.Count(a=>a=='y') >= 2) {
            char[] newY = other.Where(a=>a=='y').Skip(1).ToArray();
            other = other.Where(a=>a!='y').Concat(new char[]{'y'}).ToArray();
            return ans + this.getAns(other, newY);
        }
        
        return ans;
    }




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

8
yywxvyyy


";
        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