結果

問題 No.723 2つの数の和
ユーザー zunda1stzunda1st
提出日時 2018-08-03 23:33:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 72,944 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 21:40:54
合計ジャッジ時間 1,992 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
 
#define shosu setprecision(10)
typedef long long ll;

int N;
int X;
int a[100002];

int main(){
    cin>>N>>X;
    rep0(i,N) cin>>a[i];
    sort(a,a+N);
    ll ans=0;
    rep0(i,N){
        int b=X-a[i];
        int u=(upper_bound(a,a+N,b)-a);
        int l=(lower_bound(a,a+N,b)-a);
        ans+=(u-l);
    }
    cout<<ans<<endl;
    return 0;
    
}
0