Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
229131 | 顾欣薇 | 提高:贪心:数列极差 | C++ | Accepted | 100 | 0 MS | 268 KB | 550 | 2024-01-05 20:57:40 |
#include <bits/stdc++.h> using namespace std; priority_queue<int>min1; priority_queue<int,vector<int>,greater<int> >max1; int n,a,b; int main() { cin >>n; for (int i=1;i<=n;i++) { cin >>a; max1.push(a); min1.push(a); } a=0; while(min1.size()!=1) { a=min1.top(); min1.pop(); b=min1.top(); min1.pop(); min1.push(a*b+1); a=0;b=0; } while(max1.size()!=1) { a=max1.top(); max1.pop(); b=max1.top(); max1.pop(); max1.push(a*b+1); a=0;b=0; } cout << max1.top()-min1.top(); return 0; }