QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572852#9313. Make MaxtantianWA 0ms3552kbC++14819b2024-09-18 16:35:522024-09-18 16:35:53

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 16:35:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-09-18 16:35:52]
  • 提交

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'