結果

問題 No.723 2つの数の和
ユーザー youthfuldays072youthfuldays072
提出日時 2018-10-14 19:18:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 2,247 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 91,108 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 20:19:09
合計ジャッジ時間 1,850 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 20 ms
5,376 KB
testcase_04 AC 26 ms
5,376 KB
testcase_05 AC 23 ms
5,376 KB
testcase_06 AC 24 ms
5,376 KB
testcase_07 AC 12 ms
5,376 KB
testcase_08 AC 13 ms
5,376 KB
testcase_09 AC 26 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 15 ms
5,376 KB
testcase_13 AC 27 ms
5,376 KB
testcase_14 AC 9 ms
5,376 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 17 ms
5,376 KB
testcase_17 AC 22 ms
5,376 KB
testcase_18 AC 16 ms
5,376 KB
testcase_19 AC 29 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 30 ms
5,376 KB
testcase_24 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int tb[100010];

int main()
{
	int n, x; cin >> n >> x;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int buf; cin >> buf;
		a[i] = buf;
		tb[buf]++;
	}
	
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		int d = x - a[i];

		if (d>= 0 && d<=100000) {
			ans += (tb[x - a[i]]);
		}
		
	}

	cout << ans << endl;

	return 0;

}
0