# 14044: 【原4044】STL系列-map/pq

### 题目描述

author: Engineev 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4044

## Description

1. 日天学长去买了一个大小为\(y\)的苹果，并把放到了第\(x\)堆苹果中。
2. 日天学长吃掉了第\(x\)堆苹果中最大的那个苹果。（确保那一堆有苹果）
3. 日天学长问你第\(x\)堆苹果中最大的那一个有多大。

## Input Format

1. 第\(x\)堆和日天买的新苹果的大小\(y\)
2. 第\(x\)堆
3. 第\(x\)堆

## Sample Input

``````10
1 205994652 166436591
3 205994652
1 205994652 442744844
2 205994652
1 802512269 688107128
1 46206654 191520151
3 205994652
2 205994652
1 802512269 487115216
3 802512269
``````

## Sample Output

``````166436591
166436591
688107128
``````

## FineArtz's solution

``````/* STL-map/pq */
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
using namespace std;

int main(){
int n, t, x, y;
scanf("%d", &n);
//cin >> n;
map<int, priority_queue<int>> apple;
while (n--){
scanf("%d", &t);
//cin >> t;
switch(t){
case 1:
scanf("%d%d", &x, &y);
//cin >> x >> y;
apple[x].push(y);
break;
case 2:
scanf("%d", &x);
//cin >> x;
apple[x].pop();
break;
case 3:
scanf("%d", &x);
//cin >> x;
printf("%d\n", apple[x].top());
//cout << apple[x].top() << endl;
break;
default:
break;
}
}
return 0;
}
``````