結果

問題 No.723 2つの数の和
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2018-08-25 14:11:08
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 3,402 ms
コンパイル使用メモリ 69,316 KB
実行使用メモリ 16,032 KB
最終ジャッジ日時 2023-09-13 19:17:57
合計ジャッジ時間 24,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,500 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 TLE -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 AC 254 ms
6,272 KB
testcase_15 AC 664 ms
8,940 KB
testcase_16 AC 1,233 ms
12,600 KB
testcase_17 AC 1,804 ms
14,252 KB
testcase_18 AC 20 ms
12,256 KB
testcase_19 AC 25 ms
12,088 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 TLE -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, tables, algorithm

let
  tmp, arr = map(split readLine stdin, parseInt)
  (N, X) = (tmp[0], tmp[1])
var
  a = initCountTable[int]()
  i, ans = 0

for i, ai in arr:
  inc a, ai

var b = newSeq[int](len a)

for k, v in a:
  b[i] = k
  i += 1

sort(b, cmp)

for i, v in b[0 .. b.len div 2]:
  if X - v in b:
    ans += a[v] * a[X - v] * (2 - int(v == X - v))

echo ans
0