結果
問題 | No.723 2つの数の和 |
ユーザー |
![]() |
提出日時 | 2019-05-26 23:52:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 796 ms |
コンパイル使用メモリ | 94,556 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2024-09-17 15:24:15 |
合計ジャッジ時間 | 2,224 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<vector> #include<string> #include<sstream> #include<cmath> #include<numeric> #include<map> #include<stack> #include<queue> using namespace std; long long mod = 1e9 + 7; int main(void) { long long n, x; cin >> n >> x; vector<long long> a(n); map<long long, long long> m; for(int i=0; i<n; i++){ cin >> a[i]; m[a[i]]++; } long long cnt = 0; for(auto i=m.begin(); i!=m.end(); i++) { if(i->first*2 == x) { cnt += i->second * (i->second); }else{ if(m.find(x - i->first) == m.end()) continue; cnt += i->second * m[x - i->first]; } } cout << cnt << endl; return 0; } // EOF