-
个人简介
#include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int>> q; int main(){ int n,x,ans=0; cin>>n; while(n--){ cin>>x; q.push(x); } while(q.size()!=1){ int a=q.top();q.pop(); int b=q.top();q.pop(); q.push(a+b); ans+=a+b; } cout<<ans; return 0; }
#include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int>> q; int main(){ int n,x,ans=0; cin>>n; while(n--){ cin>>x; q.push(x); } while(q.size()!=1){ int a=q.top();q.pop(); int b=q.top();q.pop(); q.push(a+b); ans+=a+b; } cout<<ans; return 0; }
我长得非常非常帅 #include<bits/stdc++.h> using namespace std; deque q; int main(){ int n,i=0,c; cin>>n; while(n--){ char a,b; cin>>a>>b; if(a=='A'){ if(b=='L')q.push_front(++i); else q.push_back(++i); }
else{ cin>>c; if(b=='L'){ while(q.size()&&c--)q.pop_front(); } else{ while(c--&&q.size())q.pop_back(); } } } while(q.size()){ cout<<q.front()<<endl; q.pop_front(); } return 0;
}
-
通过的题目
-
最近活动
题目标签
- 初窥门径
- 8
- GESP一级
- 5
- 顺序结构
- 4
- 分支结构
- 3
- 蓝桥杯
- 3
- 循环结构
- 3
- 202309
- 2
- 略有小成
- 2
- 样题
- 2
- 202303
- 1
- 其他
- 1
- 位运算
- 1
- GESP
- 1