Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133783 莫栋涛 数列极差问题 C++ 通过 100 0 MS 244 KB 601 2024-03-02 09:19:20

Tests(3/3):


#include <bits/stdc++.h> #define ll long long using namespace std; int main() { while (true) { int n; cin >> n; if (n == 0) return 0; priority_queue<ll, vector<ll>, greater<ll> > lq; priority_queue<ll, vector<ll>, less<ll> > gq; for (int i = 1; i <= n; i++) { ll x; cin >> x; lq.push(x); gq.push(x); } while (lq.size() != 1) { ll a, b; a=lq.top(); lq.pop(); b=lq.top(); lq.pop(); lq.push(a*b+1); a=gq.top(); gq.pop(); b=gq.top(); gq.pop(); gq.push(a*b+1); } cout << lq.top() - gq.top() << endl; } }


测评信息: