結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2019-03-09 10:37:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 541 bytes |
コンパイル時間 | 1,849 ms |
コンパイル使用メモリ | 178,884 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-06-23 15:11:35 |
合計ジャッジ時間 | 3,460 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, x; cin >> n >> x; vector<int> A(n); map<int, int> mp; for(int i = 0; i < n; i++){ cin >> A[i]; mp[A[i]]++; } if(x == 0){ cout << (long long)n * (long long)n << endl; return 0; } sort(A.begin(), A.end()); int ans = 0; for(int i = 0; i < n; i++){ int r = x - A[i]; ans += mp[r]; } cout << ans << endl; return 0; }