結果
問題 | No.723 2つの数の和 |
ユーザー |
![]() |
提出日時 | 2020-06-27 03:46:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 514 bytes |
コンパイル時間 | 1,335 ms |
コンパイル使用メモリ | 173,956 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-07-05 08:33:32 |
合計ジャッジ時間 | 3,502 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef long double ld;int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);ll N,X;cin>>N>>X;map<ll, ll> mp;for(int i=0;i<N;i++){int a;cin>>a;mp[a]++;}ll ans=0;for(auto &kv:mp){auto num = kv.first;auto cnt = kv.second;if (num*2==X){ans += cnt * cnt;} else if(num*2<X){ans += cnt * mp[X-num]*2;}}cout<<ans<<endl;return 0;}