QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#570639#9313. Make Maxzeroeeeooo#WA 0ms3808kbC++201.2kb2024-09-17 16:51:092024-09-17 16:51:09

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-17 16:51:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-09-17 16:51:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '/n'

void solve(){
    int n;
    cin>>n;
    vector<int>a={0};
    int ans = 0;
    for(int i = 1;i<=n;i++){
        int num;cin>>num;
        a.push_back(num);
    }
    stack<int>num;
    num.push(1);
    vector<int>change;
    for(int i = 2;i<=n;i++){
        while(num.size()&&a[i]>a[num.top()]){
            change.push_back(num.top());
            num.pop();
            ans++;
        }
        num.push(i);
        int cnt = 0;
        int last = -1;
        if(change.size())last = change[0];
        for(int i = 0;i<change.size();i++){
            if(last != a[change[i]])ans+=cnt;
            last = a[change[i]];
            cnt++;
            a[change[i]]=a[num.top()];
            num.push(change[i]);
        }
        change.clear();
    }
    int last = a[num.top()],cnt = 0;
    while(num.size()){
        if(last!=a[num.top()]){
            last = a[num.top()];
            ans+=cnt;
        }
        num.pop();
        cnt++;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    
    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: 3808kb

input:

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

output:

112142012142312142312142

result:

wrong output format Expected integer, but "112142012142312142312142" found