結果

問題 No.190 Dry Wet Moist
ユーザー 14番14番
提出日時 2016-05-02 10:58:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 3,499 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 106,496 KB
実行使用メモリ 41,984 KB
最終ジャッジ日時 2024-04-15 09:09:16
合計ジャッジ時間 6,396 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
18,176 KB
testcase_01 AC 34 ms
18,176 KB
testcase_02 AC 37 ms
18,048 KB
testcase_03 AC 34 ms
18,048 KB
testcase_04 AC 31 ms
18,304 KB
testcase_05 AC 34 ms
18,432 KB
testcase_06 AC 35 ms
18,048 KB
testcase_07 AC 43 ms
18,944 KB
testcase_08 AC 43 ms
18,560 KB
testcase_09 AC 38 ms
18,816 KB
testcase_10 AC 38 ms
18,816 KB
testcase_11 AC 39 ms
18,688 KB
testcase_12 AC 144 ms
28,544 KB
testcase_13 AC 179 ms
35,072 KB
testcase_14 AC 139 ms
28,032 KB
testcase_15 AC 192 ms
35,968 KB
testcase_16 AC 232 ms
37,760 KB
testcase_17 AC 59 ms
20,680 KB
testcase_18 AC 118 ms
25,984 KB
testcase_19 AC 232 ms
37,632 KB
testcase_20 AC 171 ms
34,304 KB
testcase_21 AC 55 ms
20,352 KB
testcase_22 AC 279 ms
40,832 KB
testcase_23 AC 280 ms
41,216 KB
testcase_24 AC 281 ms
41,984 KB
testcase_25 AC 33 ms
18,304 KB
testcase_26 AC 31 ms
18,048 KB
testcase_27 AC 188 ms
34,560 KB
testcase_28 AC 96 ms
23,168 KB
testcase_29 AC 123 ms
25,856 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 inputCount = int.Parse(Reader.ReadLine());
        
        List<int> minus = new List<int>();
        List<int> plus = new List<int>();
        List<int> zero = new List<int>();
        
        int[] inpt = Reader.GetInt();
        for(int i=0; i<inpt.Length; i++) {
            if(inpt[i] > 0) {
                plus.Add(inpt[i]);
            } else if(inpt[i] < 0) {
                minus.Add(inpt[i]);
            } else
            {
                zero.Add(inpt[i]);
            }
        }
        
        // dry
        List<int> list = new List<int>(minus);
        list.Sort();
        list.Reverse();
        List<int> target = new List<int>(zero);
        target.AddRange(plus);
        target.Sort();
        List<int> amari = new List<int>();
        int targetIndex = 0;
        int dry = 0;
        for(int i=0; i<list.Count && targetIndex < target.Count; i++) {
            if(list[i] + target[targetIndex] < 0) {
                dry++;
                targetIndex++;
            }
        }
        
        dry += (minus.Count - dry) / 2;
        int wet = 0;
        list =  new List<int>(plus);
        list.Sort();
        target = new List<int>(minus);
        target.AddRange(zero);
        target.Sort();
        target.Reverse();
        targetIndex = 0;

        for(int i=0; i<list.Count && targetIndex < target.Count; i++) {
            if(list[i] + target[targetIndex] > 0) {
                wet++;
                targetIndex++;
            }
        }
        wet += (plus.Count - wet) / 2;
        int moist = zero.Count / 2;
        int minusIndex = 0;
        int plusIndex = 0;
        minus.Sort();
        plus.Sort();
        plus.Reverse();
        while (minusIndex < minus.Count && plusIndex < plus.Count)
        {
            if(minus[minusIndex] + plus[plusIndex] < 0) {
                minusIndex++;
            } else if(minus[minusIndex] + plus[plusIndex] > 0) {
                plusIndex++;
            } else
            {
                moist++;
                minusIndex++;
                plusIndex++;
            }
        }
        Console.WriteLine(dry + " " + wet + " " + moist);
        
    }



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


4
-4 -3 -2 -1 1 2 3 4



 
";
        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();
            }
        }
        public static int[] GetInt(char delimiter = ' ', bool trim = false)
        {
            string inptStr = ReadLine();
            if (trim)
            {
                inptStr = inptStr.Trim();
            }
            string[] inpt = inptStr.Split(delimiter);
            int[] ret = new int[inpt.Length];
            for (int i = 0; i < inpt.Length; i++)
            {
                ret[i] = int.Parse(inpt[i]);
            }
            return ret;
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0