結果

問題 No.723 2つの数の和
ユーザー bluemeganebluemegane
提出日時 2018-09-05 20:06:24
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 109,988 KB
実行使用メモリ 35,568 KB
最終ジャッジ日時 2024-04-27 14:37:33
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,244 KB
testcase_01 AC 25 ms
24,244 KB
testcase_02 AC 26 ms
24,240 KB
testcase_03 AC 61 ms
31,496 KB
testcase_04 AC 68 ms
32,588 KB
testcase_05 AC 64 ms
33,808 KB
testcase_06 AC 66 ms
32,080 KB
testcase_07 AC 46 ms
28,948 KB
testcase_08 AC 49 ms
28,772 KB
testcase_09 AC 68 ms
32,164 KB
testcase_10 AC 43 ms
26,396 KB
testcase_11 AC 32 ms
24,856 KB
testcase_12 AC 52 ms
30,084 KB
testcase_13 AC 70 ms
30,484 KB
testcase_14 AC 42 ms
27,836 KB
testcase_15 AC 49 ms
27,032 KB
testcase_16 AC 55 ms
30,588 KB
testcase_17 AC 63 ms
31,596 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 27 ms
26,516 KB
testcase_21 AC 25 ms
22,328 KB
testcase_22 AC 25 ms
24,112 KB
testcase_23 AC 67 ms
35,568 KB
testcase_24 AC 43 ms
26,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var d = new Dictionary<int, int>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++)
        {
            var w = int.Parse(line[i]);
            if (d.ContainsKey(w)) d[w]++;
            else d[w] = 1;
        }
        var ans = 0L;
        foreach (var x in d)
        {
            var s = a - x.Key;
            if (x.Key == s) ans += x.Value * x.Value;
            else if (d.ContainsKey(s))
                ans += x.Value * d[s];
        }
        Console.WriteLine(ans);
    }
}
0