QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#576237#9313. Make MaxsushayingWA 29ms7208kbC++201.1kb2024-09-19 19:33:122024-09-19 19:33:13

Judging History

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

  • [2024-09-19 19:33:13]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:7208kb
  • [2024-09-19 19:33:12]
  • 提交

answer

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

using i64 = long long;
using u64 = unsigned long long;

constexpr int N = 1e5 + 10;
constexpr int mod = 1e9 + 7;
constexpr int inf = 0x3f3f3f3f;
constexpr i64 infll = 0x3f3f3f3f3f3f3f3f;

#define debug(x) std::cerr << #x << " = " << x << std::endl
void solve(){
    int n;
    cin>>n;
    vector<int>a(n+1),stk1(n+1),stk2(n+1),l(n+1),r(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ed1=0,ed2=0;
    for(int i=1;i<=n;i++)
    {
        while(a[i]>a[stk1[ed1]]&&ed1)
        {
           ed1--; 
        } 
        l[i]=stk1[ed1]+1;
        stk1[++ed1]=i;
    }
    for(int i=n;i>=1;i--)
    {
        if(a[i]>a[stk2[ed2]]&&ed2)
        {
            ed2--;
        }   
        r[i]=stk2[ed2]-1;
        stk2[++ed2]=i;
    }
    l[1]=1;
    r[n]=n;
    i64 ans = 0;
    for(int i=1;i<=n;i++) ans+=r[i]-l[i];
    cout<<ans<<'\n';

}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int t = 1;
    std::cin >> t;
    while(t--){

        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

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

output:

1
0
3
3

result:

ok 4 number(s): "1 0 3 3"

Test #2:

score: -100
Wrong Answer
time: 29ms
memory: 7208kb

input:

2
198018
875421126 585870339 471894633 383529988 625397685 944061047 704695631 105113224 459022561 760848605 980735314 847376362 980571959 329939331 644635272 326439858 752879510 837384394 175179068 182094523 397239381 1199016 185143405 279638454 252374970 822030887 860312140 137248166 993229443 164...

output:

1815741
1665104

result:

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