結果

問題 No.723 2つの数の和
ユーザー bluemeganebluemegane
提出日時 2018-09-05 19:54:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 112,200 KB
実行使用メモリ 34,840 KB
最終ジャッジ日時 2024-04-27 14:36:57
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,092 KB
testcase_01 AC 27 ms
22,324 KB
testcase_02 AC 28 ms
26,280 KB
testcase_03 AC 63 ms
33,676 KB
testcase_04 AC 73 ms
32,208 KB
testcase_05 AC 69 ms
32,024 KB
testcase_06 AC 72 ms
32,464 KB
testcase_07 AC 51 ms
28,988 KB
testcase_08 AC 53 ms
26,984 KB
testcase_09 WA -
testcase_10 AC 53 ms
26,504 KB
testcase_11 AC 36 ms
25,244 KB
testcase_12 AC 55 ms
27,892 KB
testcase_13 AC 76 ms
32,524 KB
testcase_14 AC 44 ms
26,164 KB
testcase_15 AC 50 ms
28,912 KB
testcase_16 AC 60 ms
28,276 KB
testcase_17 AC 70 ms
31,976 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 27 ms
24,240 KB
testcase_21 AC 27 ms
24,116 KB
testcase_22 AC 28 ms
24,364 KB
testcase_23 AC 75 ms
34,692 KB
testcase_24 AC 45 ms
26,136 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++;
            else if (d.ContainsKey(s))
                ans += x.Value * d[s];
        }
        Console.WriteLine(ans);
    }
}
0