QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#573436#9313. Make MaxwxsqWA 0ms3636kbC++201.1kb2024-09-18 18:44:372024-09-18 18:44:39

Judging History

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

  • [2024-09-18 18:44:39]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-09-18 18:44:37]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
using LL = long long;

int main(){

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        vector<int> a(n + 2);
        a[0] = a[n + 1] = 2e9;
        for(int i = 1; i <= n; i++) cin >> a[i];
        LL ans = 0;
        {
            vector<int> stk{0};
            for(int i = 1; i <= n; i++){
                while(!stk.empty() and a[stk.back()] < a[i]){
                    stk.pop_back();
                }
                ans += i - stk.back() - 1;
                cout<<stk.back()<<endl;
                stk.push_back(i);
            }
        }
        {
            vector<int> stk{n + 1};
            for(int i = n; i >= 1; i--){
                while(!stk.empty() and a[stk.back()] < a[i]) stk.pop_back();
                if (a[stk.back()] != a[i]) ans += stk.back() - i - 1;
                stk.push_back(i);
            }
        }
        cout << ans << '\n';
    }

}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3636kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

0
0
1
0
1
0
0
1
2
0
4
5
6
3
0
0
0
3

result:

wrong answer 1st numbers differ - expected: '1', found: '0'