結果
問題 |
No.3197 Frequency Counter
|
ユーザー |
|
提出日時 | 2025-07-11 21:33:09 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 812 ms / 2,000 ms |
コード長 | 1,589 bytes |
コンパイル時間 | 3,733 ms |
コンパイル使用メモリ | 79,932 KB |
実行使用メモリ | 70,960 KB |
最終ジャッジ日時 | 2025-07-11 21:33:27 |
合計ジャッジ時間 | 13,956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { int n = sc.nextInt(); Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for (int i = 0; i < n; i++) { int d = sc.nextInt(); map.put(d, map.getOrDefault(d, 0) + 1); } int q = sc.nextInt(); for (int i = 0; i < q; i++) { int x = sc.nextInt(), k = sc.nextInt(); int cnt = map.getOrDefault(x, 0); out.println(cnt >= k ? "Yes" : "No"); } out.close(); } static Kattio sc = new Kattio(); static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static class Kattio { static BufferedReader r; static StringTokenizer st; public Kattio() { r = new BufferedReader(new InputStreamReader(System.in)); } public String next() { try { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(r.readLine()); } return st.nextToken(); } catch (Exception e) { return null; } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } } }