Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
138842 | 陈家宝 | 数列极差问题 | C++ | 通过 | 100 | 0 MS | 256 KB | 596 | 2024-03-19 16:18:02 |
#include<bits/stdc++.h> #define int long long using namespace std; int n,a[50005]; priority_queue<int>q1; priority_queue<int,vector<int>,greater<int> >q2; signed main() { while(cin>>n&&n>0){ while(!q1.empty()) q1.pop(); while(!q2.empty()) q2.pop(); for(int i=1;i<=n;i++) cin>>a[i],q1.push(a[i]),q2.push(a[i]); while(q2.size()>1){ int y=q2.top();q2.pop(); int yy=q2.top();q2.pop(); q2.push(y*yy+1); } while(q1.size()>1){ int y=q1.top();q1.pop(); int yy=q1.top();q1.pop(); q1.push(y*yy+1); } cout<<q2.top()-q1.top()<<"\n"; } return 0; }