#include <iostream>
#include <set>
using namespace std;
struct AppleClass
{
string id;
int price;
bool operator<(const AppleClass& o) const
{
return price > o.price;
}
};
int main()
{
set<AppleClass> myapples;
myapples.insert({"apple1", 500});
myapples.insert({"apple1", 600});
myapples.insert({"apple1", 400});
auto e = myapples.find({"apple13", 500});
cout << e->id << "," << e->price << endl;
for (auto& apple : myapples)
{
cout << apple.id << "," << apple.price << endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEFwcGxlQ2xhc3MKewogICAgc3RyaW5nIGlkOwogICAgaW50IHByaWNlOwogICAgCiAgICBib29sIG9wZXJhdG9yPChjb25zdCBBcHBsZUNsYXNzJiBvKSBjb25zdCAKICAgIHsKICAgIAlyZXR1cm4gcHJpY2UgPiBvLnByaWNlOwkKICAgIH0KfTsKCmludCBtYWluKCkgCnsKCXNldDxBcHBsZUNsYXNzPiBteWFwcGxlczsKCW15YXBwbGVzLmluc2VydCh7ImFwcGxlMSIsIDUwMH0pOwoJbXlhcHBsZXMuaW5zZXJ0KHsiYXBwbGUxIiwgNjAwfSk7CglteWFwcGxlcy5pbnNlcnQoeyJhcHBsZTEiLCA0MDB9KTsKCQoJYXV0byBlID0gbXlhcHBsZXMuZmluZCh7ImFwcGxlMTMiLCA1MDB9KTsKCWNvdXQgPDwgZS0+aWQgPDwgIiwiIDw8IGUtPnByaWNlIDw8IGVuZGw7CgkKCWZvciAoYXV0byYgYXBwbGUgOiBteWFwcGxlcykKCXsKCQljb3V0IDw8IGFwcGxlLmlkIDw8ICIsIiA8PCBhcHBsZS5wcmljZSA8PCBlbmRsOwoJCQoJfQp9