結果

問題 No.723 2つの数の和
ユーザー playrollerplayroller
提出日時 2018-08-30 00:22:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 939 bytes
コンパイル時間 1,218 ms
コンパイル使用メモリ 98,792 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 20:52:44
合計ジャッジ時間 2,780 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 30 ms
4,352 KB
testcase_04 AC 41 ms
4,348 KB
testcase_05 AC 34 ms
4,352 KB
testcase_06 AC 38 ms
4,352 KB
testcase_07 AC 16 ms
4,352 KB
testcase_08 AC 19 ms
4,348 KB
testcase_09 AC 38 ms
4,352 KB
testcase_10 AC 17 ms
4,352 KB
testcase_11 AC 4 ms
4,352 KB
testcase_12 AC 21 ms
4,348 KB
testcase_13 AC 37 ms
4,352 KB
testcase_14 AC 10 ms
4,372 KB
testcase_15 AC 16 ms
4,348 KB
testcase_16 AC 23 ms
4,352 KB
testcase_17 AC 31 ms
4,352 KB
testcase_18 AC 22 ms
4,348 KB
testcase_19 AC 36 ms
4,352 KB
testcase_20 AC 1 ms
4,356 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 48 ms
4,352 KB
testcase_24 AC 12 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int n, x;
  cin >> n >> x;
  vi a(n);
  rep(i, 0, n) cin >> a[i];

  sort(all(a));
  i64 ans = 0;
  rep(i, 0, n) {
    if(a[i] + *(lower_bound(all(a), x - a[i])) == x) {
      ans += (upper_bound(all(a), x - a[i]) - a.begin()) - (lower_bound(all(a), x - a[i]) - a.begin());
    }
  }
  cout << ans << endl;
}
0