QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574933#9313. Make MaxcuteWA 0ms3812kbC++14776b2024-09-19 09:03:172024-09-19 09:03:18

Judging History

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

  • [2024-09-19 09:03:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-09-19 09:03:17]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;


void solve(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	a[0] = a[n+1] = 2e9;
	for(int i = 1;  i<= n; i++)cin >> a[i];
	long long ans = 0;
	vector<int> stk;
	stk.push_back(0);
	for(int i = 1; i <= n; i++){
		while(!stk.empty() && a[stk.back()]<a[i])stk.pop_back();
		ans += i - stk.back()-1;
		cout << ans <<endl;
		stk.push_back(i);
	}
	stk.clear();
	stk.push_back(n+1);
	for(int i = n; i >= 1; i--){
		while(!stk.empty() && a[stk.back()]<a[i])stk.pop_back();
		if(a[stk.back()]!=a[i])
		ans +=stk.back()- i  -1;
		cout <<ans <<endl;
		stk.push_back(i);
	}
	cout << ans <<endl;
}


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

详细

Test #1:

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

input:

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

output:

0
1
1
1
1
0
0
0
0
0
0
0
0
3
3
3
3
3
3
3
3
3
3
3
3
0
1
3
3
3
3
3

result:

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