10816デジタルカード2
5050 ワード
10816デジタルカード2
https://www.acmicpc.net/problem/10816
https://www.acmicpc.net/problem/10816
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<long long> vec;
int N,M;
long long temp;
cin >> N;
while (N--)
{
cin >> temp; vec.push_back(temp);
}
sort(vec.begin(), vec.end());
cin >> M;
while (M--)
{
cin >> temp;
cout << upper_bound(vec.begin(), vec.end(), temp) - lower_bound(vec.begin(), vec.end(), temp) << " ";
}
}
小数と大数を利用して、二分探索で必要な数を見つけ、その数を見つけることができます.Reference
この問題について(10816デジタルカード2), 我々は、より多くの情報をここで見つけました https://velog.io/@hopark/10816-lowerbound-upperboundテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol