?
?
??在蓝桥网站上面的两道题
https://www.lanqiao.cn/problems/1113/learning/?page=1&first_category_id=1&problem_id=1113
#include <bits/stdc++.h>
using namespace std;
int main()
{
queue<string> V,N;
int m;cin>>m;
while(m--)
{
string op;cin>>op;
if(op=="IN")
{
string name,pos;
cin>>name>>pos;
if(pos=="V")
{
V.push(name);
}
else
{
N.push(name);
}
}
else
{
string pos;
cin>>pos;
if(pos=="V")
{
V.pop();
}
else
{
N.pop();
}
}
}
while(V.size())
{
cout<<V.front()<<endl;
V.pop();
}
while(N.size())
{
cout<<N.front()<<endl;
N.pop();
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;cin>>n;
priority_queue<long long,vector<long long>,greater<long long>> pq;
for(int i=1;i<=n;i++)
{
long long x;
cin>>x;
pq.push(x);
}
long long count=0;
while(pq.size()>=2)
{
long long x=pq.top();
pq.pop();
long long y=pq.top();
pq.pop();
count+=x+y;
pq.push(x+y);
}
cout<<count;
return 0;
}
?