Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133765 吴晨曦 数列极差问题 C++ 通过 100 0 MS 248 KB 618 2024-03-02 09:10:36

Tests(3/3):


#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (!n) break; priority_queue <int, vector <int>, greater <int> > q1; priority_queue <int> q2; for (int i = 1, u; i <= n; i++) { cin >> u; q1.push(u); q2.push(u); } while (q1.size() != 1) { int tmp1 = q1.top(); q1.pop(); int tmp2 = q1.top(); q1.pop(); q1.push(tmp1 * tmp2 + 1); } while (q2.size() != 1) { int tmp1 = q2.top(); q2.pop(); int tmp2 = q2.top(); q2.pop(); q2.push(tmp1 * tmp2 + 1); } cout << q1.top() - q2.top() << endl; } }


测评信息: