QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655085 | #9442. Music Game | ucup-team1074 | WA | 0ms | 3564kb | C++23 | 1.0kb | 2024-10-19 00:26:14 | 2024-10-19 00:26:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
void solve()
{
int n;
cin >> n;
stack<int>q;
int op = 0;
for(int i = 0 ; i < n ; i ++){
int x;
cin >> x;
if(q.empty()){
q.push(x);
op += x;
}
else{
int k = q.top();
if(x > k){
op += x - k;
q.push(x);
}
else if(k > x){
while(!q.empty()){
int t = q.top();
if(t > x){
q.pop();
}
else{
break;
}
}
q.push(x);
}
}
}
cout << op;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(10);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
2 3 3 5 2 4 7
output:
3
result:
wrong answer 1st words differ - expected: '831870305', found: '3'