結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2020-09-03 20:31:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 1,676 ms |
コンパイル使用メモリ | 172,748 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 00:46:10 |
合計ジャッジ時間 | 2,894 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, x; cin >> n >> x; vector<ll> a(n); for (auto&& ia : a) cin >> ia; sort(a.begin(), a.end()); ll res{ 0 }; for (int i = 0; i < n; ++i) { if (a[i] > x) break; auto it = equal_range(a.begin(), a.end(), x - a[i]); if (it.first != a.end() && *it.first == x - a[i]) res += (it.first == it.second ? 1 : it.second - it.first); } cout << res << "\n"; return 0; }