結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2019-05-26 17:22:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 666 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 77,008 KB |
実行使用メモリ | 11,116 KB |
最終ジャッジ日時 | 2024-09-17 15:17:16 |
合計ジャッジ時間 | 17,297 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 TLE * 1 -- * 6 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int MyBinarySearch(vector<int> vec, int target) { auto it = vec.begin(); int sum = 0; while (true) { if (binary_search(it, vec.end(), target)) { sum++; it = find(it, vec.end(), target)+1; } else { break; } } return sum; } int main() { int n; long x; vector<int> data; cin >> n >> x; for (int i = 0; i < n; i++) { int buff; cin >> buff; data.push_back(buff); } sort(data.begin(), data.end()); int sum = 0; for (int i = 0; i < data.size(); i++) { int target = x - data[i]; sum += MyBinarySearch(data, target); } cout << sum; return 0; }