Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133793 王泰兮 数列极差问题 C++ 通过 100 0 MS 252 KB 682 2024-03-02 09:21:36

Tests(3/3):


#include <bits/stdc++.h> using namespace std; int main(){ int n; while (cin >> n&&n!=0){ priority_queue<int, vector<int>, greater<int> > a; priority_queue<int, vector<int>, less<int> > b; for (int i = 1;i<=n;i++){ int k; cin >> k; a.push(k); b.push(k); } for (int i = 1;i<=n-1;i++){ int q1 = a.top(); a.pop(); int q2 = a.top(); a.pop(); a.push(q1*q2+1); q1 = b.top(); b.pop(); q2 = b.top(); b.pop(); b.push(q1*q2+1); } cout << a.top() - b.top() << endl;}}


测评信息: