From b919d17cea5808a447397d244a8d9d1a473eeed7 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 29 Nov 2025 00:12:57 +0700 Subject: [PATCH] feat(cpp): add tknpcb_06 --- cpp/tknpcb_06.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cpp/tknpcb_06.cpp diff --git a/cpp/tknpcb_06.cpp b/cpp/tknpcb_06.cpp new file mode 100644 index 0000000..436828d --- /dev/null +++ b/cpp/tknpcb_06.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int N, Q; + cin >> N >> Q; + vector A(N); + for (int i = 0; i < N; ++i) cin >> A[i]; + + while (Q--) { + int x; + cin >> x; + auto lower = lower_bound(A.begin(), A.end(), x); + auto upper = upper_bound(A.begin(), A.end(), x); + cout << upper - lower << "\n"; + } + + return 0; +}