QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#573497#9313. Make MaxwxsqWA 0ms3624kbC++20957b2024-09-18 19:01:352024-09-18 19:01:40

Judging History

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

  • [2024-09-18 19:01:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-09-18 19:01:35]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
void solve() {
    int n; cin >> n;
    vector<int>a(n+1);

    for(int i = 1 ; i <= n ; i++) {
        cin >> a[i];
    }

    ll ans = 0;

    vector<int>stk;
    vector<int>anss(n+1);
    for(int i = 1 ; i <= n ; i++){
        while(!stk.empty() && a[stk.back()] < a[i]) stk.pop_back();
        
        if(!stk.empty()) ans += i-stk.back()-1;
        else ans += i-1;
        cout<<ans<<" "<<a[i]<<endl;
        stk.push_back(i);
    }
    vector<int>stk2;
    for(int i = n ; i >= 1 ; i--){
        while(!stk2.empty() && a[stk2.back()] < a[i]) stk2.pop_back();
        if(!stk2.empty() && a[i]!=a[stk2.back()]) ans += stk2.back()-i-1;
        else if(stk2.empty())ans += n-i;
        cout<<ans<<" "<<a[i]<<endl;
        stk2.push_back(i);
    }
    cout<<ans<<endl;
}

int main()
{
    int t; cin >> t;
    while(t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

0 1
1 2
1 2
1 1
1
0 2
0 2
0 2
0 2
0
0 1
0 1
0 1
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 2
3 1
3 1
3 1
3
0 1
1 2
3 3
3 3
3 2
3 1
3

result:

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