QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#572863 | #9313. Make Max | tantian | WA | 1ms | 3604kb | C++14 | 827b | 2024-09-18 16:36:59 | 2024-09-18 16:37:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int FieldSum(vector<int> &v)
{
v.push_back(INT_MAX);
stack<int> st;
int sum = 0;
for (int i = 0; i < (int)v.size(); i++)
{
if (st.empty() || v[st.top()] > v[i])
{
st.push(i);
}
else
{
while (!st.empty() && v[st.top()] <= v[i])
{
int top = st.top();
st.pop();
sum += (i - top - 1);
}
st.push(i);
}
}
return sum;
}
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> v(n + 1);
for (int i = 0; i < n; i++)
cin >> v[i];
cout << FieldSum(v) << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3604kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1 1 1 1
result:
wrong answer 2nd numbers differ - expected: '0', found: '1'