//这道题只需要在输入的时候和MAX,MIN比较并更新即可 //肌肉记忆直接用优先队列了... #include "stdio.h" #include "queue" using namespace std; int main(){ int N; priority_queue<int> myPQueueMax; priority_queue<int> myPQueueMin; while (scanf("%d",&N)!=EOF){ for (int i = 0; i < N; ++i) { int num; scanf("%d",&num); myPQueueMax.push(num); myPQueueMin.push(-num); } printf("%d ",myPQueueMax.top()); printf("%d\n",-myPQueueMin.top()); while (!myPQueueMax.empty()) myPQueueMax.pop(); while (!myPQueueMin.empty()) myPQueueMin.pop(); } }