#include #include #include using namespace std; struct agent { int poradi; string name; bool sell; float price; }; bool cmp(const agent a, const agent b) { return a.price > b.price; } bool cmp2(const agent a, const agent b) { return a.poradi <= b.poradi; } int main() { string line; while (cin) { string issuer; int bids; cin >> bids >> issuer; if (bids == 0 && issuer == "END") return 0; vector agenti; for (int i=0; i> a.name >> action >> a.price; a.sell = action == "sell"; a.poradi = i; agenti.push_back(a); } sort(agenti.begin(), agenti.end(), cmp); vector result(agenti.size()); for (int i=0; i vydri; int inc,mez; if (ag.sell) { inc = -1; mez = -1; } else { inc = 1; mez = agenti.size(); } for (int j=i; j!=mez; j+=inc) { if (ag.sell != agenti[j].sell) vydri.push_back(agenti[j]); } sort(vydri.begin(), vydri.end(), cmp2); result[ag.poradi] = ag.name + ":"; if (vydri.size() > 0) { for (int i=0; i