Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
139795 | 刘星辰liuxingchen | 数列极差问题 | C++ | 通过 | 100 | 0 MS | 252 KB | 650 | 2024-03-25 21:13:33 |
#include<bits/stdc++.h> using namespace std; int n; priority_queue<int> q1; priority_queue<int,vector<int>,greater<int> > q2; int t; int main() { while(cin>>n) { if(!n) { return 0; } while(!q1.empty()) { q1.pop(); q2.pop(); } for(int i=1;i<=n;i++) { cin>>t; q1.push(t); q2.push(t); } while(q1.size()!=1) { t=q1.top(); q1.pop(); t*=q1.top(); t++; q1.pop(); q1.push(t); } while(q2.size()!=1) { t=q2.top(); q2.pop(); t*=q2.top(); t++; q2.pop(); q2.push(t); } cout<<abs(q1.top()-q2.top()); cout<<endl; } return 0; }