結果
| 問題 | No.723 2つの数の和 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-24 00:57:56 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 470 bytes |
| 記録 | |
| コンパイル時間 | 401 ms |
| コンパイル使用メモリ | 80,752 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-23 20:35:26 |
| 合計ジャッジ時間 | 1,538 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
int main() {
int N, X;
cin >> N >> X;
int a[N];
for (int i = 0; i < N; i++) cin >> a[i];
sort(a, a + N);
LL ans = 0;
for (int i = 0; i < N; i++) {
int *p = lower_bound(a, a + N, X - a[i]);
int *q = upper_bound(a, a + N, X - a[i]);
if (a[i] + *p == X) ans += q - p;
}
cout << ans << endl;
}