結果

問題 No.723 2つの数の和
ユーザー suzuken_wsuzuken_w
提出日時 2019-10-01 14:56:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 174,756 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-14 08:34:54
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 108 ms
9,344 KB
testcase_04 AC 148 ms
10,112 KB
testcase_05 AC 131 ms
10,368 KB
testcase_06 AC 135 ms
10,112 KB
testcase_07 AC 56 ms
7,492 KB
testcase_08 AC 65 ms
7,768 KB
testcase_09 AC 153 ms
11,136 KB
testcase_10 AC 52 ms
7,156 KB
testcase_11 AC 12 ms
6,944 KB
testcase_12 AC 76 ms
8,388 KB
testcase_13 AC 174 ms
11,904 KB
testcase_14 AC 32 ms
6,940 KB
testcase_15 AC 59 ms
7,740 KB
testcase_16 AC 96 ms
9,600 KB
testcase_17 AC 134 ms
10,880 KB
testcase_18 AC 18 ms
6,944 KB
testcase_19 AC 35 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 117 ms
10,240 KB
testcase_24 AC 39 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
map<int,ll> mp;
int main(){
  int n,m;
  cin>>n>>m;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
ll ans=0;
for(int i=0;i<n;i++){
     ll tmp=m-a[i];

     if(tmp==a[i]) ans+=mp[a[i]]*mp[a[i]];
     else ans+=mp[tmp]*mp[a[i]]*2;
     mp[a[i]]=0;mp[tmp]=0;
}
cout<<ans<<endl;
}
0