結果

問題 No.190 Dry Wet Moist
ユーザー NoNo
提出日時 2015-06-19 18:19:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 2,238 bytes
コンパイル時間 5,858 ms
コンパイル使用メモリ 106,652 KB
実行使用メモリ 40,492 KB
最終ジャッジ日時 2023-09-21 09:47:03
合計ジャッジ時間 6,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
20,928 KB
testcase_01 AC 62 ms
20,948 KB
testcase_02 AC 62 ms
21,064 KB
testcase_03 AC 61 ms
18,956 KB
testcase_04 AC 62 ms
20,800 KB
testcase_05 AC 63 ms
20,908 KB
testcase_06 AC 63 ms
20,968 KB
testcase_07 AC 70 ms
21,092 KB
testcase_08 AC 71 ms
21,224 KB
testcase_09 AC 71 ms
21,124 KB
testcase_10 AC 70 ms
21,092 KB
testcase_11 AC 71 ms
21,036 KB
testcase_12 AC 129 ms
27,096 KB
testcase_13 AC 153 ms
36,896 KB
testcase_14 AC 128 ms
24,968 KB
testcase_15 AC 160 ms
35,348 KB
testcase_16 AC 184 ms
36,696 KB
testcase_17 AC 81 ms
22,196 KB
testcase_18 AC 117 ms
26,452 KB
testcase_19 AC 182 ms
38,688 KB
testcase_20 AC 151 ms
36,008 KB
testcase_21 AC 79 ms
23,832 KB
testcase_22 AC 192 ms
39,668 KB
testcase_23 AC 198 ms
40,080 KB
testcase_24 AC 195 ms
40,492 KB
testcase_25 AC 65 ms
22,852 KB
testcase_26 AC 62 ms
21,012 KB
testcase_27 AC 153 ms
34,632 KB
testcase_28 AC 103 ms
23,184 KB
testcase_29 AC 113 ms
28,408 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.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());
            Array.Sort(A);

            int i = 0;
            int j = 2 * N - 1;
            int dry = 0;
            int wet = 0;
            int moi = 0;

            while (i < j)
            {
                if (A[i] + A[j] < 0)
                {
                    dry++;
                    i++;
                    j--;
                }
                else
                {
                    j--;
                }
            }

            i = 0;
            j = 2 * N - 1;
            while (i < j)
            {
                if (A[i] + A[j] > 0)
                {
                    wet++;
                    i++;
                    j--;
                }
                else
                {
                    i++;
                }
            }

            i = 0;
            j = 2 * N - 1;
            while (i < j)
            {
                if (A[i] + A[j] == 0)
                {
                    moi++;
                    i++;
                    j--;
                }
                else
                {
                    if (Math.Abs(A[i]) > Math.Abs(A[j]))
                    {
                        i++;
                    }
                    else
                    {
                        j--;
                    }
                }
            }

            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