結果

問題 No.723 2つの数の和
ユーザー TomoProgTomoProg
提出日時 2018-10-18 00:00:15
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,309 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 110,860 KB
実行使用メモリ 45,860 KB
最終ジャッジ日時 2024-04-20 20:50:49
合計ジャッジ時間 6,343 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
32,632 KB
testcase_01 AC 33 ms
25,288 KB
testcase_02 AC 33 ms
25,280 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 94 ms
33,584 KB
testcase_14 AC 51 ms
26,968 KB
testcase_15 AC 59 ms
27,860 KB
testcase_16 AC 70 ms
27,964 KB
testcase_17 AC 79 ms
30,624 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 29 ms
23,224 KB
testcase_22 AC 30 ms
24,916 KB
testcase_23 TLE -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    public class Program
    {
        static void Main(string[] args)
        {
            new Program().Main2(Console.In, Console.Out);
        }

        public void Main2(TextReader reader, TextWriter writer)
        {
            var sum = int.Parse(reader.ReadLine().Split()[1]);
            var progression = reader.ReadLine().Split().Select(x => int.Parse(x)).ToList();
            var combinationNum = 0;

            progression.Sort();
            int anotherCache = -1;
            int countCache = -1;
            foreach(var num in progression)
            {
                if (num >= sum) break;
                var another = Math.Abs(sum - num);

                if (another == anotherCache)
                {
                    combinationNum += countCache;
                    break;
                }
                var anotherList = progression.FindAll(n => n == another);
                combinationNum += anotherList.Count;

                anotherCache = another;
                countCache = anotherList.Count;
            }
            writer.WriteLine(combinationNum);
        }
    }
}
0