結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2023-04-22 11:03:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 2,436 ms |
コンパイル使用メモリ | 74,928 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 00:38:17 |
合計ジャッジ時間 | 2,551 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int N,X; cin >> N >> X; vector<int> a(N); for(int i=0; i<N; i++){ cin >> a[i]; } sort(a.begin(), a.end()); long long int ans=0; for(int i = 0; i < N; i++){ ans += upper_bound(a.begin(), a.end(), (X - a[i])) - lower_bound(a.begin(), a.end(), (X -a[i])); } cout << ans << endl; return 0; }