QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578528 | #9313. Make Max | aikongsky | WA | 0ms | 3576kb | C++14 | 690b | 2024-09-20 19:48:46 | 2024-09-20 19:48:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int a[N];
int t,n;
void solve()
{
cin>>n;
ll sum = 0;
for(int i = 1;i <= n;i++)
{
cin>>a[i];
}
vector<int>s(1);
s.push_back(1);
a[0] = 0x3f3f3f;
for(int i = 1;i <= n;i++)
{
while(a[s.back()] < a[i]) s.pop_back();
sum += i - s.back() - 1;
s.push_back(i);
}
s.clear();
s.push_back(n);
a[n+1] = 0x3f3f3f;
for(int i = n ;i >= 1;i--)
{
while(a[s.back()] < a[i]) s.pop_back();
if(a[s.back()] != a[i]) sum += s.back() - i - 1;
s.push_back(i);
}
cout<<sum<<endl;
}
int main()
{
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: 3576kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
0 -1 2 2
result:
wrong answer 1st numbers differ - expected: '1', found: '0'