結果

問題 No.723 2つの数の和
ユーザー bluemeganebluemegane
提出日時 2018-09-05 19:50:29
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 796 ms
コンパイル使用メモリ 109,904 KB
実行使用メモリ 35,236 KB
最終ジャッジ日時 2024-04-27 14:36:28
合計ジャッジ時間 3,104 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,332 KB
testcase_01 AC 24 ms
24,076 KB
testcase_02 AC 23 ms
22,064 KB
testcase_03 AC 56 ms
31,192 KB
testcase_04 AC 64 ms
32,472 KB
testcase_05 AC 62 ms
32,088 KB
testcase_06 AC 64 ms
30,040 KB
testcase_07 AC 44 ms
29,056 KB
testcase_08 AC 45 ms
26,724 KB
testcase_09 WA -
testcase_10 AC 41 ms
27,028 KB
testcase_11 AC 32 ms
24,988 KB
testcase_12 AC 50 ms
28,428 KB
testcase_13 AC 65 ms
32,636 KB
testcase_14 AC 37 ms
25,868 KB
testcase_15 AC 43 ms
26,740 KB
testcase_16 AC 53 ms
28,816 KB
testcase_17 AC 61 ms
31,848 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 24 ms
24,336 KB
testcase_21 AC 23 ms
24,208 KB
testcase_22 AC 26 ms
24,208 KB
testcase_23 AC 66 ms
35,236 KB
testcase_24 AC 41 ms
28,508 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 = 0;
        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