結果

問題 No.723 2つの数の和
ユーザー TqkTqk
提出日時 2018-08-04 08:32:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 2,567 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 165,868 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 21:46:24
合計ジャッジ時間 2,698 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #


#include "bits/stdc++.h"
//#include <iostream>
//#include <vector>
//#include <string>
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
	dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
	dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
	dx4[4] = { 0,1,0,-1 },
	dy4[4] = { 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }




#define P3 pair<P, lint>

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

	lint n, x; cin >> n >> x;
	ivec a; int in;
	rep(i, n) {
		cin >> in;
		a.pb(in);
	}
	vsort(a);
	lint ans = 0;
	pair<ivec::iterator,ivec::iterator> rn;
	rep(i, n) {
		rn = equal_range(all(a), x - a[i]);
		if (rn.first != a.end())ans += rn.second - rn.first;
	}
	co(ans);
	gc();
}
0