Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133634 黄一航 数列极差问题 C++ 通过 100 0 MS 260 KB 638 2024-03-02 08:47:57

Tests(3/3):


#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n; cin >> n; while (n != 0) { priority_queue<int> q1; priority_queue<int,vector<int>,greater<int> > q2; for (int i = 1; i <= n; i++) { int x; cin >> x; q1.push(x); q2.push(x); } while (q1.size() >= 2) { int x = q1.top(); q1.pop(); int y = q1.top(); q1.pop(); q1.push(x * y + 1); } while (q2.size() >= 2) { int x = q2.top(); q2.pop(); int y = q2.top(); q2.pop(); q2.push(x * y + 1); } printf("%lld\n",abs(q2.top() - q1.top())); cin >> n; } return 0; }


测评信息: