結果

問題 No.723 2つの数の和
ユーザー umezo
提出日時 2020-09-16 04:59:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 2,531 ms
コンパイル使用メモリ 199,240 KB
最終ジャッジ日時 2025-01-14 15:11:55
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     scanf("%lld", &y);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,x;
  cin>>n>>x;
  
  map<int,ll> m;
  rep(i,n){
    ll y;
    scanf("%lld", &y);
    m[y]++;
  }
  
  ll sum=0;
  for(auto t:m){
    if(t.first>2*x) break;
    else sum+=t.second*m[x-t.first];
  }
  cout<<sum<<endl;
  return 0;
}
0