結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-06 16:10:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 455 bytes |
| コンパイル時間 | 840 ms |
| コンパイル使用メモリ | 75,136 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 18:12:56 |
| 合計ジャッジ時間 | 1,864 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using i64 = long long;
int main(void) {
int n; i64 x; scanf("%d%lld", &n, &x);
vector<i64> a(n);
for(int i=0; i<n; ++i) { scanf("%lld", &a[i]); }
sort(begin(a), end(a));
i64 res = 0;
for(int i=0; i<n; ++i) {
i64 y = x - a[i];
res += upper_bound(begin(a), end(a), y)
- lower_bound(begin(a), end(a), y);
}
printf("%lld\n", res);
return 0;
}