题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
#include <functional> #include <iostream> #include <deque> #include <queue> #include <unordered_set> using namespace std; //哈希表+优先级队列 int main() { priority_queue<int, vector<int>, greater<>> pq; int map[501] = {0}; int numLine; cin >> numLine; while (numLine--) {//一共numLine行输入 int num; cin >> num; if (map[num] == 0) { pq.push(num); } map[num]++; } while (!pq.empty()) { cout << pq.top() << endl; pq.pop(); } } // 64 位输出请用 printf("%lld")