QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#567483 | #9313. Make Max | nelie | WA | 1ms | 5840kb | C++14 | 2.3kb | 2024-09-16 12:13:12 | 2024-09-16 12:13:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 200100
#define PII pair<int,int>
stack<PII>q;
stack<PII>h;
queue<PII>hh;
priority_queue<PII,vector<PII>,less<PII>>qq;
//priority_queue<PII,vector<PII>,greater<PII>>qqq;
int t;
int n;
int a[N];
int b[N];
int v[N];
int l,r,mid;
int maxn;
int ans;
int sss;
signed main()
{
cin>>t;
while(t--)
{
ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
a[n+1]=2e18;
int i=1;
while(i<=n)
{
while(i<=n&&a[i]>=a[i+1])
{
q.push({a[i],1});
i++;
}
while(i<=n&&a[i]<=a[i+1])
{
h.push({a[i],1});
i++;
}
if(h.size()==0)continue;
//cout<<1<<endl;
maxn=h.top().first;
while(!h.empty())
{
qq.push(h.top());
h.pop();
}
//cout<<maxn<<endl;
while(!q.empty()&&q.top().first<=maxn)
{
qq.push(q.top());
q.pop();
}
q.push(qq.top());
sss=qq.top().first;
qq.pop();
//cout<<i<<endl;
//cout<<q.top().first<<endl;
while(!qq.empty())
{
//cout<<ans<<endl;
//cout<<qq.top().first<<endl;
if(qq.top().first!=sss)
{
l++;
}
ans+=qq.top().second*l;
q.top().second+=qq.top().second;
sss=qq.top().first;
qq.pop();
}
}
//cout<<ans<<endl;
//ans=0;
hh.push(q.top());
q.pop();
while(!q.empty())
{
if(q.top().first==hh.front().first)
hh.front().second+=q.top().second;
else
hh.push(q.top());
q.pop();
}
while(!hh.empty())
{
ans+=hh.front().second*(hh.size()-1);
hh.pop();
}
cout<<ans<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5840kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 1 9 7
result:
wrong answer 2nd numbers differ - expected: '0', found: '1'