#28685: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
d545. 2. 抽紙牌(poker) -- 98學年度台北市資訊學科能力競賽 | From: [219.85.177.13] | 發表日期 : 2021-12-26 23:28

#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<char, int> poker;

bool cmp(poker x, poker y){
if (x.second!=y.second){
return x.second>y.second;
}
else {
return x.first>y.first;
}
}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
poker a[52];
int n, m;
while (cin >> n){
for (int i=0; i<n; i++){
cin >> a[i].first >> a[i].second;
}
cin >> m;
sort(a, a+n, cmp);
cout << a[m-1].first <<" "<< a[m-1].second <<endl;
}
}
 
ZeroJudge Forum