結果

問題 No.723 2つの数の和
ユーザー zunda1st
提出日時 2018-08-03 23:33:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 72,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 17:41:29
合計ジャッジ時間 1,777 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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