結果

問題 No.723 2つの数の和
ユーザー lapilapi
提出日時 2019-03-31 13:05:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 692 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 102,180 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 09:28:51
合計ジャッジ時間 2,476 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 13 ms
6,940 KB
testcase_14 AC 4 ms
6,944 KB
testcase_15 AC 5 ms
6,944 KB
testcase_16 AC 9 ms
6,940 KB
testcase_17 AC 10 ms
6,940 KB
testcase_18 AC 10 ms
6,944 KB
testcase_19 AC 14 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 20 ms
6,944 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int a[100001];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, X;
	cin >> N >> X;
	for (int i = 0; i < N; i++) cin >> a[i];

	ll ans = 0LL;

	for (int i = 0; i < N; i++) {
		ans += upper_bound(a, a + N, X - a[i]) - lower_bound(a, a + N, X - a[i]);
	}

	cout << ans << endl;

	return 0;
}
0