結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-09-05 20:09:30 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 2,000 ms |
| コード長 | 777 bytes |
| コンパイル時間 | 983 ms |
| コンパイル使用メモリ | 112,340 KB |
| 実行使用メモリ | 31,744 KB |
| 最終ジャッジ日時 | 2024-11-15 17:21:23 |
| 合計ジャッジ時間 | 3,065 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
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, long>();
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);
}
}
bluemegane