結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2025-10-08 01:41:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 528 bytes |
コンパイル時間 | 3,090 ms |
コンパイル使用メモリ | 274,672 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-08 01:41:39 |
合計ジャッジ時間 | 4,888 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int N, X, a[1 << 17]; long long ans = 0, cnt[1 << 17]; signed main() { cin.tie(0)->sync_with_stdio(0); cin >> N >> X; rep(i, N) { cin >> a[i]; ++cnt[a[i]]; } if (X == 0) { ans = cnt[0] * (cnt[0] + 1) / 2; cout << ans << endl; return 0; } rep(i, N) { if (a[i] + a[i] == X) ++ans; else if (0 <= X - a[i] && X - a[i] < 1 << 17) ans += cnt[X - a[i]]; } cout << ans << endl; }