結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2019-03-09 10:41:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 1,725 ms |
コンパイル使用メモリ | 178,476 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2024-06-23 15:11:39 |
合計ジャッジ時間 | 3,407 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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, long long> 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()); long long ans = 0; for(int i = 0; i < n; i++){ int r = x - A[i]; ans += mp[r]; } cout << ans << endl; return 0; }