結果

問題 No.723 2つの数の和
ユーザー aaaaaa
提出日時 2018-11-08 22:52:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,348 bytes
コンパイル時間 1,221 ms
コンパイル使用メモリ 100,288 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 22:43:34
合計ジャッジ時間 1,935 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>

using namespace std;


int main(){
	int i, j, k;
	long long n, x;
	vector<bool>flag(100009, false);
	vector<long long>list;
	vector<int>list2(100005, 0);
	long cnt2 = 0;

	cin >> n >> x;


	for (i = 0; i < n; i++) {
		long long num;
		cin >> num;

		if (num <= 100000) {
			list2[num]++;
		}

		if ( (x - num > 100000) || (x - num < 0)) {

		}
		else {
			//if (flag[x - num] == true) cnt2++;
			flag[x - num] = true;
		}

		list.push_back(num);

	}

	long sum = 0;

	for (i = 0; i < 100000; i++) {
		if (x - i == i) {
			while(list2[i]>=2)
			{
				sum += list2[i] * (list2[i] - 1);
				list2[i]--;
			}
			//sum--;
			continue;
		}

		if (x - i <= 100000 && x - i >= 0) {
			sum += (list2[i] * list2[x - i]);
		}
	}

	cout << sum << endl;


	//long long cnt = 0;

	//sort(list.begin(), list.end());

	//for (i = 0; i < n; i++) {
	//	if (flag[list[i]] == true) {
	//		if ( i != 0 && list[i] == list[i - 1]) cnt2++;
	//		cnt++;
	//	}
	//}

	//cout << cnt + cnt2 << endl;










	getchar();
	getchar();
	return 0;
}
0