QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#601870 | #9313. Make Max | zhk88719 | WA | 26ms | 7964kb | C++14 | 1.3kb | 2024-09-30 15:05:10 | 2024-09-30 15:05:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200005;
int t;
int skt1[N],skt2[N],ans1[N],ans2[N];
ll tt1,tt2,n,a[N],sum,num;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin>>t;
while(t--)
{
memset(ans1,0,sizeof ans1);
memset(ans2,0,sizeof ans2);
tt1=0,tt2=0,sum=0,num=0;
cin>>n;
for(int i=0;i<n;i++)
{
num=0;
cin>>a[i];
while(tt1&&skt1[tt1]<a[i])
{
num=ans1[tt1];
tt1--;
ans1[tt1]+=num;
}
if(skt1[tt1]==a[i])
{
skt1[++tt1]=a[i];
ans1[tt1]++;
continue;
}
sum+=num;
skt1[++tt1]=a[i];
ans1[tt1]++;
}
for(int i=n-1;i>-1;i--)
{
num=0;
while(tt2&&skt2[tt2]<a[i])
{
num=ans2[tt2];
tt2--;
ans2[tt2]+=num;
}
sum+=num;
skt2[++tt2]=a[i];
ans2[tt2]++;
}
cout<<sum;
if(t>0) cout<<endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5692kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 0 3 3
result:
ok 4 number(s): "1 0 3 3"
Test #2:
score: -100
Wrong Answer
time: 26ms
memory: 7964kb
input:
2 198018 875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...
output:
263280616956 806919695647
result:
wrong answer 1st numbers differ - expected: '4084978', found: '263280616956'