結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2018-09-05 19:50:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 810 ms |
コンパイル使用メモリ | 104,320 KB |
実行使用メモリ | 30,080 KB |
最終ジャッジ日時 | 2024-11-15 17:20:00 |
合計ジャッジ時間 | 3,530 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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); } }