QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640816#7616. Jump Graphrotcar07WA 1ms5660kbC++20614b2024-10-14 16:15:282024-10-14 16:15:29

Judging History

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

  • [2024-10-14 16:15:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5660kb
  • [2024-10-14 16:15:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=3e5+5;
int n,a[maxn];
typedef long long ll;
ll ans[maxn];
int main(){
	std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;for(int i=1;i<=n;i++) cin>>a[i];
	a[0]=a[n+1]=n+1;
	stack<int> s;s.push(0);
	ll cur=0;
	for(int i=1;i<=n;i++){
		ans[i]=cur;
		while(a[s.top()]<a[i]) s.pop();
		cur+=i-s.top();s.push(i);
	}
	while(!s.empty()) s.pop();cur=0;s.push(n+1);
	for(int i=n;i>=1;i--){
		ans[i]+=cur;
		while(a[s.top()]<a[i]) s.pop();
		cur+=s.top()-i;s.push(i);
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<" ";cout<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3556kb

input:

6
1 6 3 2 5 4

output:

11 7 7 7 6 8 

result:

ok single line: '11 7 7 7 6 8 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

2
1 2

output:

1 1 

result:

ok single line: '1 1 '

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5660kb

input:

36
9 29 1 3 14 31 24 21 10 18 22 16 8 7 15 12 17 19 25 28 27 34 11 6 32 4 20 13 2 35 23 26 33 36 30 5

output:

101 98 99 99 100 87 81 79 79 79 73 72 71 71 70 72 72 77 83 94 107 100 120 120 116 118 116 116 116 113 142 142 143 143 175 175 

result:

wrong answer 1st lines differ - expected: '92 89 90 90 91 78 73 71 71 71 ...110 107 136 136 137 136 168 168', found: '101 98 99 99 100 87 81 79 79 7...16 113 142 142 143 143 175 175 '