int main() {
	scanf("%d", &n);
	a[0] = INF;
	REP(i,1,n) {
		scanf("%d", a+i);
		int pre = 0;
		while (a[s[top]]<=a[i]) pre=s[top--];
		L[i] = pre;
		R[s[top]] = i;
		s[++top] = i;;
	}
}

 处理完后根为s[0]

相关文章:

猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
相关资源
相似解决方案