文章
43
粉丝
180
获赞
21
访问
196.1k
#include <bits/stdc++.h>
using namespace std;
struct plural
{
int mod;
string val;
bool operator< (const plural &W)const
{
return mod < W.mod;
}
};
int get(string s)
{
int x = atoi(s.c_str());
return x * x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
priority_queue<plural> heap;
int n;
cin >> n;
while (n -- )
{
string op;
cin >> op;
if (op == "Pop")
{
if (heap.empty()) cout << "empty\n";
else
{
cout << heap.top().val << "\n";
heap.pop();
cout << "SIZE = " << heap.size() << "\n";
}
}
else
{
plural w;
cin >> w.val;
string s;
for (auto v : w.val)
{
if (v != '+' && v != 'i') s += v;
else
{
w.mod += get(s);
s.clear();
}
}
w.mod += get(s);
heap.push(w);
cout << "SIZE = " << heap.size() << "\n";...
登录后发布评论
暂无评论,来抢沙发