結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2019-10-01 14:56:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 694 bytes |
コンパイル時間 | 1,550 ms |
コンパイル使用メモリ | 178,240 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-10-03 05:42:12 |
合計ジャッジ時間 | 3,700 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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; }