QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#571334 | #9313. Make Max | Drunk_all_over_the_city | WA | 265ms | 17264kb | C++14 | 1.5kb | 2024-09-17 22:03:45 | 2024-09-17 22:03:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vc vector
#define lowbit(x) (x&-x)
int t[200005];
void solve()
{
int n;cin>>n;
vc<int>a(n+1);
int tt=0;
int max=0,sum=0,ans=0;
map<int,int>cnt;
for(int i=1;i<=n;i++)
{
cin>>a[i];
cnt[a[i]]=1;
if(a[i]>max)
{
max=a[i];
for(int i=tt;i>=0;i--)
{
t[i]=0;
}
tt=0;
t[tt]=max;
tt++;
ans=ans+i-1;
sum=0;
}
else if(a[i]==max)
{
for(int i=tt;i>=0;i--)
{
t[i]=0;
}
tt=0;
t[tt]=max;
tt++;
sum=0;
}
else
{
int z=0;
while(tt--)
{
if(t[tt]>a[i])
{
t[tt+1]=a[i];
tt++;
if(z==1)
ans+=sum;
break;
}
else if(t[tt]==a[i])
{
sum=0;
break;
}
else
{
t[tt]=0;
sum++;
z=1;
}
}
tt++;
ans=ans+tt-1;
}
}
cout<<ans<<endl;
}
signed main()
{
int m;cin>>m;while(m--)solve();return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
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: 265ms
memory: 17264kb
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:
4038247503 6152379948
result:
wrong answer 1st numbers differ - expected: '4084978', found: '4038247503'