#9658: 我的解法


dse12345z (dse12345z)

學校 : 不指定學校
編號 : 47834
來源 : [61.216.89.235]
最後登入時間 :
2024-07-15 17:37:35
d984. 棄保效應 -- 板橋高中教學題 | From: [114.43.215.74] | 發表日期 : 2015-02-16 15:02

#include <map>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
map <long long int, string> candidateDictionary;

long long int aTicket, bTicket, cTicket;
long long int ticketArray[3];
    
while (cin >> aTicket >> bTicket >> cTicket) {
ticketArray[0] = aTicket;
ticketArray[1] = bTicket;
ticketArray[2] = cTicket;

candidateDictionary[aTicket] = "A";
candidateDictionary[bTicket] = "B";
candidateDictionary[cTicket] = "C";

sort(ticketArray, ticketArray + 3);

if (ticketArray[2] > ticketArray[0] + ticketArray[1]) {
cout << candidateDictionary[ticketArray[2]] << endl;
}
else if (ticketArray[0] < ticketArray[1]) {
cout << candidateDictionary[ticketArray[1]] << endl;
}
else {
cout << candidateDictionary[ticketArray[0]] << endl;
}
}
return 0;
}
 
參考看看 :D 
 
ZeroJudge Forum