結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2025-08-10 00:31:46 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 475 bytes |
コンパイル時間 | 3,129 ms |
コンパイル使用メモリ | 285,820 KB |
実行使用メモリ | 8,240 KB |
最終ジャッジ日時 | 2025-08-10 00:31:51 |
合計ジャッジ時間 | 5,266 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, x; cin >> n >> x; vector<int> a(n); rep(i, n) cin >> a[i]; map<int, int> cnt; ll ans = 0; rep(i, n) { if (cnt.contains(x - a[i])) ans += 2 * cnt[x - a[i]]; if (a[i] * 2 == x) ans++; cnt[a[i]]++; } cout << ans << '\n'; return 0; }