結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 27 ms
6,944 KB
testcase_05 AC 24 ms
6,940 KB
testcase_06 AC 26 ms
6,940 KB
testcase_07 AC 13 ms
6,944 KB
testcase_08 AC 13 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 WA -
testcase_13 AC 27 ms
6,944 KB
testcase_14 AC 8 ms
6,940 KB
testcase_15 AC 12 ms
6,944 KB
testcase_16 AC 18 ms
6,940 KB
testcase_17 AC 24 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 WA -
testcase_24 AC 9 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--;
			sum += pow(list2[i], list2[i]);
			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