QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575167#9313. Make MaxtilennWA 0ms3576kbC++23897b2024-09-19 11:02:132024-09-19 11:02:14

Judging History

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

  • [2024-09-19 11:02:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3576kb
  • [2024-09-19 11:02:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
typedef long long LL;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n + 2);
    a[0] = a[n + 1] = 1e9 + 1;
    stack<int> stk;
    vector<int> l(n + 1),r(n + 1);
    stk.push(0);
    for(int i = 1;i <= n;i++){
        while(stk.size() && a[stk.top()] < a[i])stk.pop();
        l[i] = stk.top();
        stk.push(i);
    }
    while(stk.size())stk.pop();
    stk.push(n + 1);
    for(int i = n;i >= 1;i--){
        while(stk.size() && a[stk.top()] < a[i])stk.pop();
        r[i] = stk.top();
        stk.push(i);
    }
    LL res = 0;
    for(int i = 1;i <= n;i++){
        res += r[i] - l[i] - 1;
    }
    



}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:


result:

wrong answer Answer contains longer sequence [length = 4], but output contains 0 elements