Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
133617 | 柯昊阳 | 数列极差问题 | C++ | 输出超限 | 0 | 2 MS | 248 KB | 572 | 2024-03-02 08:36:22 |
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; while(n!=0){ priority_queue<long long> q1; priority_queue<long long,vector<long long>,greater<long long> >q2; for(int i = 0;i<n;i++){ int x; cin>>x; q1.push(x); q2.push(x); } while(q1.size()>1){ int s1 = q1.top(); q1.pop(); int s2 = q1.top(); q1.pop(); q1.push(s1*s2+1); } while(q2.size()>1){ int s1 = q2.top(); q2.pop(); int s2 = q2.top(); q2.pop(); q2.push(s1*s2+1); } cout<<q2.top()-q1.top()<<endl; } }