結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2019-09-18 23:52:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 439 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 172,740 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-07-17 23:31:16 |
合計ジャッジ時間 | 3,967 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin>>n>>x; map<int, long> m; for (int i=0; i<n; i++) { int a; cin>>a; ++m[a]; } long long ans = 0; for (auto e: m) { int a = e.first; long cnt = e.second; auto it = m.lower_bound(x - a); if (it == m.end()) { continue; } else if ((*it).first == x - a) { ans += cnt * (*it).second; } } cout<<ans<<endl; }