結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2020-10-07 12:38:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 719 ms |
コンパイル使用メモリ | 74,112 KB |
実行使用メモリ | 14,336 KB |
最終ジャッジ日時 | 2024-07-20 03:22:22 |
合計ジャッジ時間 | 7,579 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 -- * 2 |
other | -- * 22 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; vector<int> a(100005); int n,x; bool binary_search(int x){ int l = 0,r = n; int mid = (l+r)/2; while(r-l > 0){ if(a[mid] == x){ return true; }else if(a[mid] < x){ l = mid; }else if(a[mid] > x){ r = mid; } } return false; } int main(){ cin >> n >> x; for(int i=0;i < n;i++){ cin >> a[i]; } sort(a.begin(),a.end()); int ans = 0; for(int i=0;i < n;i++){ if(binary_search(x - a[i])) ans++; } cout << ans << endl; return 0; }