結果

問題 No.190 Dry Wet Moist
ユーザー NoNo
提出日時 2015-06-18 18:22:32
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,817 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 106,332 KB
実行使用メモリ 46,456 KB
最終ジャッジ日時 2023-09-21 09:29:52
合計ジャッジ時間 15,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
22,028 KB
testcase_01 AC 66 ms
22,036 KB
testcase_02 AC 66 ms
22,152 KB
testcase_03 AC 67 ms
21,996 KB
testcase_04 AC 67 ms
20,064 KB
testcase_05 AC 67 ms
24,040 KB
testcase_06 AC 66 ms
21,976 KB
testcase_07 WA -
testcase_08 AC 75 ms
22,180 KB
testcase_09 AC 75 ms
22,296 KB
testcase_10 WA -
testcase_11 AC 75 ms
24,280 KB
testcase_12 WA -
testcase_13 TLE -
testcase_14 WA -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Text;
using System.Threading.Tasks;

namespace foryuki
{
    class Program
    {
        static int[] n;

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = ConvertStringArrayToIntArray(Console.ReadLine().Split());


            var d = A.Where(x => x < 0).OrderBy(x => x).ToArray();
            var cm1 = A.Where(x => x >= 0).OrderByDescending(x => x).ToArray();

            int cnt = 0;
            int k = 0;
            for (int i = 0; i < d.Length; i++)
            {
                for (int j = k; j < cm1.Length; j++)
                {
                    if (d[i] + cm1[j] < 0)
                    {
                        cnt++;
                        k = j + 1;
                        break;
                    }
                }
            }
            if (cnt < d.Length)
            {
                cnt = cnt + (d.Length - cnt) / 2;
            }

            int dry = cnt;

            //----------------------------

            var w = A.Where(x => x > 0).OrderByDescending(x => x).ToArray();
            var cm2 = A.Where(x => x <= 0).OrderBy(x => x).ToArray();

            cnt = 0;
            k = 0;
            for (int i = 0; i < w.Length; i++)
            {
                for (int j = k; j < cm2.Length; j++)
                {
                    if (w[i] + cm2[j] > 0)
                    {
                        cnt++;
                        k = j + 1;
                        break;
                    }
                }
            }
            if (cnt < w.Length)
            {
                cnt = cnt + (w.Length - cnt) / 2;
            }

            int wet = cnt;

            //------------------------------

            cnt = 0;
            k = 0;
            for (int i = 0; i < d.Length; i++)
            {
                for (int j = k; j < w.Length; j++)
                {
                    if (d[i] + w[j] == 0)
                    {
                        cnt++;
                        k = j + 1;
                        break;
                    }
                }
            }
            var moi = A.Where(x => x == 0).Count() + cnt;

            Console.WriteLine("{0} {1} {2}",dry,wet,moi);
        }

        //-------------------------------------------------------------

        static int[] ConvertStringArrayToIntArray(string[] array)
        {
            return Array.ConvertAll(array, str => int.Parse(str));
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str)
            {
                list.Add(int.Parse(c));
            }
            return list;
        }
    }
}
0