結果
問題 |
No.8016 unordered_mapなるたけ落とすマン
|
ユーザー |
![]() |
提出日時 | 2020-12-14 09:44:57 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,179 bytes |
コンパイル時間 | 3,381 ms |
コンパイル使用メモリ | 85,596 KB |
実行使用メモリ | 76,256 KB |
最終ジャッジ日時 | 2024-09-20 00:34:46 |
合計ジャッジ時間 | 46,815 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | MLE * 3 |
other | TLE * 6 MLE * 42 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); MyMap exists = new MyMap(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); exists.add(x); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < m; i++) { if (i > 0) { sb.append(" "); } sb.append(exists.get(sc.nextLong())); } System.out.println(sb); } static class MyMap { ArrayList<Unit> list; public MyMap() { list = new ArrayList<>(); list.add(new Unit(0, 0)); list.add(new Unit(Long.MAX_VALUE, 0)); } public void add(long x) { int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m).idx >= x) { right = m; } else { left = m; } } if (list.get(right).idx == x) { list.get(right).value++; } else { list.add(right, new Unit(x, 1)); } } public int get(long x) { int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m).idx >= x) { right = m; } else { left = m; } } if (list.get(right).idx == x) { return list.get(right).value; } else { return 0; } } } static class Unit { long idx; int value; public Unit(long idx, int value) { this.idx = idx; this.value = value; } public String toString() { return idx + ":" + value; } } }