QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#572852 | #9313. Make Max | tantian | WA | 0ms | 3552kb | C++14 | 819b | 2024-09-18 16:35:52 | 2024-09-18 16:35:53 |
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);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
4 2 1 2 2 2 2 7 1 1 1 2 2 2 2 3 1 2 3
output:
1111
result:
wrong answer 1st numbers differ - expected: '1', found: '1111'