結果

問題 No.723 2つの数の和
ユーザー バカらっくバカらっく
提出日時 2018-08-04 23:02:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,808 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 112,108 KB
実行使用メモリ 39,872 KB
最終ジャッジ日時 2023-10-19 21:59:43
合計ジャッジ時間 3,404 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
25,628 KB
testcase_01 AC 33 ms
25,628 KB
testcase_02 AC 33 ms
25,628 KB
testcase_03 AC 69 ms
34,120 KB
testcase_04 AC 79 ms
35,252 KB
testcase_05 AC 75 ms
34,856 KB
testcase_06 AC 76 ms
35,044 KB
testcase_07 AC 55 ms
28,856 KB
testcase_08 AC 56 ms
29,060 KB
testcase_09 AC 78 ms
35,372 KB
testcase_10 AC 54 ms
28,772 KB
testcase_11 AC 40 ms
26,712 KB
testcase_12 AC 60 ms
30,612 KB
testcase_13 AC 80 ms
35,528 KB
testcase_14 AC 47 ms
27,964 KB
testcase_15 AC 55 ms
28,916 KB
testcase_16 AC 64 ms
31,120 KB
testcase_17 AC 72 ms
34,688 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 32 ms
25,628 KB
testcase_21 AC 31 ms
25,628 KB
testcase_22 AC 32 ms
25,628 KB
testcase_23 AC 81 ms
39,872 KB
testcase_24 AC 50 ms
28,168 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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        long total = inpt[1];

        long[] items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        Dictionary<long, int> dic = new Dictionary<long, int>();

        foreach(long item in items) {
            if(dic.ContainsKey(item)) {
                dic[item]++;
            } else {
                dic[item] = 1;
            }
        }

        long ans = 0;
        foreach(long key in dic.Keys) {
            long pairKey = total - key;
            if(pairKey<0) {
                continue;
            }
            if(!dic.ContainsKey(pairKey)) {
                continue;
            }
            ans += dic[key] * dic[pairKey];
        }
        Console.WriteLine(ans);

    }

    private int[] GetIntArray() {
        return Reader.ReadLine().Trim().Split(' ').Select(a => int.Parse(a)).ToArray();
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



3 4
1 2 3









";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0