回答編集履歴
1
追記
test
CHANGED
@@ -35,3 +35,39 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
lower_bound じゃなく binary_search じゃないと**一致する**要素は探せないんちゃいます?
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```C++
|
42
|
+
|
43
|
+
#include <iostream>
|
44
|
+
|
45
|
+
#include <vector>
|
46
|
+
|
47
|
+
#include <algorithm>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
int main() {
|
52
|
+
|
53
|
+
using namespace std;
|
54
|
+
|
55
|
+
vector<int> vec = { 0, 0, 1, 1, 2, 2, 3, 3, 3, 5, 6, 6, 8, 9, 9 };
|
56
|
+
|
57
|
+
int sum = 0;
|
58
|
+
|
59
|
+
for ( int n : { 8, 4, 6, 5, 0, 2, 1, 7, 9, 3 } ) {
|
60
|
+
|
61
|
+
if ( binary_search(vec.begin(), vec.end(), n ) ) {
|
62
|
+
|
63
|
+
++sum;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
cout << sum << endl;
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
```
|