結果

問題 No.3197 Frequency Counter
ユーザー elphe
提出日時 2025-07-11 23:17:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 1,155 ms
コンパイル使用メモリ 107,728 KB
実行使用メモリ 20,368 KB
最終ジャッジ日時 2025-07-11 23:17:25
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>
#include <unordered_map>

static inline std::vector<bool> solve(const uint_fast32_t N, const uint_fast32_t Q, const std::vector<uint_fast32_t>& A, const std::vector<uint_fast32_t>& x, const std::vector<uint_fast32_t>& k) noexcept
{
	std::unordered_map<uint_fast32_t, uint_fast32_t> count_of;
	count_of.reserve(N);
	for (uint_fast32_t i = 0; i != N; ++i)
		++count_of[A[i]];

	std::vector<bool> ans(Q);
	for (uint_fast32_t i = 0; i != Q; ++i)
		ans[i] = (count_of[x[i]] >= k[i]);

	return ans;
}

static inline void output(const uint_fast32_t Q, const std::vector<bool>& ans) noexcept
{
	for (uint_fast32_t i = 0; i != Q; ++i)
	{
		if (ans[i]) std::cout << "Yes\n";
		else std::cout << "No\n";
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	
	uint_fast32_t N, Q, i;
	std::cin >> N;
	std::vector<uint_fast32_t> A(N);
	for (i = 0; i != N; ++i)
		std::cin >> A[i];

	std::cin >> Q;
	std::vector<uint_fast32_t> x(Q), k(Q);
	for (i = 0; i != Q; ++i)
		std::cin >> x[i] >> k[i];

	output(Q, solve(N, Q, A, x, k));
	return 0;
}
0