結果
問題 | No.723 2つの数の和 |
ユーザー | gemmaro |
提出日時 | 2020-04-25 09:24:22 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 388 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 29,096 KB |
最終ジャッジ日時 | 2024-04-24 09:41:53 |
合計ジャッジ時間 | 5,475 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
12,160 KB |
testcase_01 | AC | 78 ms
12,288 KB |
testcase_02 | AC | 75 ms
12,032 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
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 | AC | 238 ms
26,356 KB |
testcase_14 | AC | 119 ms
16,000 KB |
testcase_15 | AC | 156 ms
18,816 KB |
testcase_16 | AC | 186 ms
22,528 KB |
testcase_17 | AC | 216 ms
24,304 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 76 ms
12,032 KB |
testcase_21 | AC | 79 ms
12,160 KB |
testcase_22 | AC | 79 ms
12,160 KB |
testcase_23 | AC | 328 ms
29,096 KB |
testcase_24 | WA | - |
コンパイルメッセージ
Syntax OK
ソースコード
# frozen_string_literal: true N, X = gets.chomp.split.map(&:to_i) A = gets.chomp.split.map(&:to_i) c = {} A.each do |a| c[a] ||= 0 c[a] += 1 end C = c B = A.uniq.sort R = (0..(B.size - 1)).map do |i| s = X - B[i] j = B[i..(N - 1)].bsearch_index { |x| x >= s } if j.nil? || B[i + j] != s 0 elsif j.zero? C[s] else C[s] * 2 end end RESULT = R.sum puts RESULT