Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
108358 Block Xuan 数列极差问题 C++ 通过 100 0 MS 256 KB 1401 2023-11-02 13:33:53

Tests(3/3):


//I am Block Xuan #include<bits/stdc++.h> //I am Block Xuan #define int long long //I am Block Xuan using namespace std; //I am Block Xuan int a[50005]; //I am Block Xuan //I am Block Xuan signed main(){ //I am Block Xuan int n; //I am Block Xuan while (cin>>n){ //I am Block Xuan if (n == 0){ //I am Block Xuan break; //I am Block Xuan } //I am Block Xuan priority_queue <int> p; //I am Block Xuan priority_queue <int,vector <int>,greater <int> > q; //I am Block Xuan for (int i = 1;i <= n;i++){ //I am Block Xuan cin>>a[i]; //I am Block Xuan p.push(a[i]); //I am Block Xuan q.push(a[i]); //I am Block Xuan } //I am Block Xuan while (p.size() >= 2){ //I am Block Xuan int a = p.top(); //I am Block Xuan p.pop(); //I am Block Xuan int b = p.top(); //I am Block Xuan p.pop(); //I am Block Xuan p.push(a * b + 1); //I am Block Xuan } //I am Block Xuan while (q.size() >= 2){ //I am Block Xuan int a = q.top(); //I am Block Xuan q.pop(); //I am Block Xuan int b = q.top(); //I am Block Xuan q.pop(); //I am Block Xuan q.push(a * b + 1); //I am Block Xuan } //I am Block Xuan cout<<q.top() - p.top()<<'\n'; //I am Block Xuan } //I am Block Xuan return 0; //I am Block Xuan } //I am Block Xuan


测评信息: