呃呃第三个数据点爆MLE。。
洛谷上我用的是优先队列。
但考试时用的是手写栈
这样A的了吗TwT
#include <bits/stdc++.h>
# include <iostream>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q1;
priority_queue<int,vector<int>,greater<int> > q2;
int arr[100005];
int main (void)
{
int n;
scanf ("%d",&n);
for (int i=0;i<n;i++)
{
scanf ("%d",&arr[i]);
q1.push(arr[i]);
}
q2.push(q1.top());
q1.pop();
while (!q1.empty())
{
while (q1.top() == q2.top())
{
q2.push(q1.top());
q1.pop();
}
while (!q1.empty() && q1.top() > q2.top())
{
q2.pop();
q2.push(q1.top());
q1.pop();
}
}
printf ("%d",q2.size());
return 0;
}