10分求调
查看原帖
10分求调
1304133
ssy111000楼主2024/11/11 22:06
#include <bits/stdc++.h>
using namespace std;
map<int ,int> mp;
int a,g1,g2;
bool b=false;
int main(){
    cin>>a;
    for(int i=1;i<=a;i++){
        cin>>g1>>g2;
        if(mp.count(g1)){
            if(g2>mp[g1]){
                mp[g1]=g2;
            }
        }else mp[g1]=g2;
    }while(!mp.empty()){
        if(b){
            cout<<',';
        }else b=true;
        cout<<'('<<mp.begin()->first<<','<<mp.begin()->second<<')';
        mp.erase(mp.begin()->first);
    }
}
2024/11/11 22:06
加载中...