QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#569887#9313. Make MaxxiaomoWA 0ms3512kbC++20814b2024-09-17 11:50:062024-09-17 11:50:09

Judging History

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

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

answer

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

void solve(){
	ll n;cin>>n;
	vector<ll> a(n);
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	stack<pair<ll,ll>> stk;
	ll res=0;
	for(ll i=0;i<n;i++){
		int idx=i;
		while(stk.size()&&stk.top().first<a[i]){
			pair<ll,ll> t=stk.top();
			while(stk.size()&&stk.top().first==t.first){
				t=stk.top();
				stk.pop();
			}
			res+=(i-t.second);
			idx=t.second;
		}
		stk.push({a[i],idx});
		//cout<<"res="<<res<<endl;
	}

	while(stk.size()){
		pair<ll,ll> t=stk.top();
		while(stk.size()&&stk.top().first==t.first){
			stk.pop();
		}
		res+=(n-1-t.second);
	}
	cout<<res<<endl;
	return;
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll _;cin>>_;
	while(_--)solve();
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

2
0
3
5

result:

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