QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
詳細信息
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'