QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#655085#9442. Music Gameucup-team1074WA 0ms3564kbC++231.0kb2024-10-19 00:26:142024-10-19 00:26:14

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 00:26:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-10-19 00:26:14]
  • 提交

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'