結果

問題 No.723 2つの数の和
ユーザー バカらっくバカらっく
提出日時 2018-08-04 23:06:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,804 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 112,640 KB
実行使用メモリ 39,860 KB
最終ジャッジ日時 2023-10-19 21:59:47
合計ジャッジ時間 3,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
25,604 KB
testcase_01 AC 32 ms
25,604 KB
testcase_02 AC 32 ms
25,604 KB
testcase_03 AC 68 ms
34,108 KB
testcase_04 AC 79 ms
35,240 KB
testcase_05 AC 76 ms
34,844 KB
testcase_06 AC 76 ms
35,032 KB
testcase_07 AC 54 ms
28,844 KB
testcase_08 AC 56 ms
29,048 KB
testcase_09 AC 77 ms
35,360 KB
testcase_10 AC 53 ms
28,760 KB
testcase_11 AC 40 ms
26,700 KB
testcase_12 AC 60 ms
30,600 KB
testcase_13 AC 79 ms
35,516 KB
testcase_14 AC 48 ms
27,952 KB
testcase_15 AC 55 ms
28,904 KB
testcase_16 AC 64 ms
31,108 KB
testcase_17 AC 72 ms
34,676 KB
testcase_18 AC 64 ms
30,312 KB
testcase_19 AC 73 ms
32,304 KB
testcase_20 AC 33 ms
25,604 KB
testcase_21 AC 33 ms
25,604 KB
testcase_22 AC 32 ms
25,604 KB
testcase_23 AC 82 ms
39,860 KB
testcase_24 AC 51 ms
28,156 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 += (long)dic[key] * (long)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 = @"






";
    }

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